Browse Source

add body do tabulky více řešení jednoho řešitele jednoho problému

middleware_test
Jonas Havelka 3 years ago
parent
commit
d05f1d631b
  1. 4
      seminar/models.py
  2. 2
      seminar/templates/seminar/odevzdavatko/seznam.html

4
seminar/models.py

@ -9,6 +9,7 @@ import logging
from django.contrib.sites.shortcuts import get_current_site from django.contrib.sites.shortcuts import get_current_site
from django.db import models from django.db import models
from django.contrib import auth from django.contrib import auth
from django.db.models import Sum
from django.utils import timezone from django.utils import timezone
from django.conf import settings from django.conf import settings
from django.utils.encoding import force_text from django.utils.encoding import force_text
@ -1134,6 +1135,9 @@ class Reseni(SeminarModelBase):
# má ForeignKey s: # má ForeignKey s:
# Hodnoceni # Hodnoceni
def sum_body(self):
return self.hodnoceni_set.all().aggregate(Sum('body'))["body__sum"]
def __str__(self): def __str__(self):
return "{}({}): {}({})".format(self.resitele.first(),len(self.resitele.all()), self.problem.first() ,len(self.problem.all())) return "{}({}): {}({})".format(self.resitele.first(),len(self.resitele.all()), self.problem.first() ,len(self.problem.all()))
# NOTE: Potenciální DB HOG (bez select_related) # NOTE: Potenciální DB HOG (bez select_related)

2
seminar/templates/seminar/odevzdavatko/seznam.html

@ -7,7 +7,7 @@
<h1>{{ dl.2 | deadline_html }}</h1> <h1>{{ dl.2 | deadline_html }}</h1>
<ul> <ul>
{% for obj in mnozina_reseni %} {% for obj in mnozina_reseni %}
<li><a href="{% url 'odevzdavatko_detail_reseni' pk=obj.id %}">{{ obj }}</a> ({{ obj.get_forma_display }} {{ obj.cas_doruceni }}) <li>{{ obj.sum_body }} b za <a href="{% url 'odevzdavatko_detail_reseni' pk=obj.id %}">{{ obj }}</a> ({{ obj.get_forma_display }} {{ obj.cas_doruceni }})
{% endfor %} {% endfor %}
</ul> </ul>
{% endfor %} {% endfor %}

Loading…
Cancel
Save