From d05f1d631bfe7bf67e4bb9a29ec0db19e8ad351a Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Thu, 16 Sep 2021 16:48:12 +0200 Subject: [PATCH] =?UTF-8?q?add=20body=20do=20tabulky=20v=C3=ADce=20=C5=99e?= =?UTF-8?q?=C5=A1en=C3=AD=20jednoho=20=C5=99e=C5=A1itele=20jednoho=20probl?= =?UTF-8?q?=C3=A9mu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/models.py | 4 ++++ seminar/templates/seminar/odevzdavatko/seznam.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/seminar/models.py b/seminar/models.py index ff10348c..e6e47a03 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -9,6 +9,7 @@ import logging from django.contrib.sites.shortcuts import get_current_site from django.db import models from django.contrib import auth +from django.db.models import Sum from django.utils import timezone from django.conf import settings from django.utils.encoding import force_text @@ -1134,6 +1135,9 @@ class Reseni(SeminarModelBase): # má ForeignKey s: # Hodnoceni + def sum_body(self): + return self.hodnoceni_set.all().aggregate(Sum('body'))["body__sum"] + def __str__(self): return "{}({}): {}({})".format(self.resitele.first(),len(self.resitele.all()), self.problem.first() ,len(self.problem.all())) # NOTE: Potenciální DB HOG (bez select_related) diff --git a/seminar/templates/seminar/odevzdavatko/seznam.html b/seminar/templates/seminar/odevzdavatko/seznam.html index 2b3f332a..bb2e4f38 100644 --- a/seminar/templates/seminar/odevzdavatko/seznam.html +++ b/seminar/templates/seminar/odevzdavatko/seznam.html @@ -7,7 +7,7 @@

{{ dl.2 | deadline_html }}

{% endfor %}