From 797256fcfed7398090cc1bd1578e3b138691c9b9 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 27 Oct 2020 23:50:05 +0100 Subject: [PATCH] =?UTF-8?q?Patch,=20kdy=C5=BE=20jsou=20bez=20=C5=99e=C5=A1?= =?UTF-8?q?en=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/odevzdavatko.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index 0a121e78..effb1135 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -50,14 +50,18 @@ class TabulkaOdevzdanychReseniView(TemplateView): hodnoceni__problem__in=[problem], # ditto ).order_by('-cas_doruceni') pocet_reseni = reseni_k_tomuto_problemu.count() - nejnovejsi = reseni_k_tomuto_problemu.first().cas_doruceni - pocet_bodu = max( - [h.body for h in m.Hodnoceni.objects.filter( - reseni__in=reseni_k_tomuto_problemu, - problem=problem, - ) - ] - ) + if pocet_reseni > 0: + nejnovejsi = reseni_k_tomuto_problemu.first().cas_doruceni + pocet_bodu = max( + [h.body for h in m.Hodnoceni.objects.filter( + reseni__in=reseni_k_tomuto_problemu, + problem=problem, + ) + ] + ) + else: + nejnovejsi = None + pocet_bodu = None ctx['radky'][resitel].append( SouhrnReseni( pocet_reseni=pocet_reseni,