From ee40db6e250bb3965f379f81608974c06e680e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 00:44:26 +0100 Subject: [PATCH] =?UTF-8?q?Add=20=C5=99e=C5=A1itelsk=C3=A9=20view=20na=20?= =?UTF-8?q?=C5=99e=C5=A1en=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminar/odevzdavatko/detail_resitele.html | 50 +++++++++++++++++++ seminar/urls.py | 2 + seminar/views/odevzdavatko.py | 29 +++++++++++ 3 files changed, 81 insertions(+) create mode 100644 seminar/templates/seminar/odevzdavatko/detail_resitele.html diff --git a/seminar/templates/seminar/odevzdavatko/detail_resitele.html b/seminar/templates/seminar/odevzdavatko/detail_resitele.html new file mode 100644 index 00000000..4e5d7848 --- /dev/null +++ b/seminar/templates/seminar/odevzdavatko/detail_resitele.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{% load static %} +{% load deadliny %} + +{% block content %} + +

Řešené problémy: {{ object.problem.all | join:", " }}

+ +

Řešitelé: {% for r in object.resitele.all %} {{ r }} + {% if forloop.revcounter0 != 0 %}, {% endif %} {% endfor %}

+ +{# https://docs.djangoproject.com/en/3.1/ref/models/instances/#django.db.models.Model.get_FOO_display #} +

Forma: {{ object.get_forma_display }}

+ +

Doručeno {{ object.cas_doruceni }}, deadline: {{object.cas_doruceni | deadline_html }}

+ +{# Soubory: #} +

Přílohy:

+{% if object.prilohy.all %} + + +{% for priloha in object.prilohy.all %} + + + + + {# TODO: Orgo-poznámka, ideálně jako formulář #} +{% endfor %} +
SouborŘešitelova poznámkaDatum
{{ priloha.split | last }}{{ priloha.res_poznamka }}{{ priloha.vytvoreno }}
+{% else %} +

Žádné přílohy

+{% endif %} + +{#

Poznámka:

#} +{#

{{ poznamka }}

#} + +{# Hodnocení: #} +

Hodnocení:

+ +{# #} +{% for h in hodnoceni %} + + + +{# #} + +{% endfor %} +
ProblémBodyČíslo pro body
{{ h.problem }}{{ h.body }}{{ h.cislo_body }}
+ +{% endblock %} diff --git a/seminar/urls.py b/seminar/urls.py index 8a6aacf4..5b71d2b3 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -142,4 +142,6 @@ urlpatterns = [ path('org/reseni/', org_required(viewMethodSwitch(get=views.DetailReseniView.as_view(), post=views.hodnoceniReseniView)), name='odevzdavatko_detail_reseni'), path('org/reseni/all', org_required(views.SeznamReseniView.as_view())), path('org/reseni/akt', org_required(views.SeznamAktualnichReseniView.as_view())), + + path('resitel/reseni/', resitel_or_org_required(views.ResitelReseniView.as_view()), name='odevzdavatko_resitel_reseni'), ] diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index ecbef01e..786d263c 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -1,3 +1,4 @@ +from django.core.exceptions import PermissionDenied from django.views.generic import ListView, DetailView, FormView from django.views.generic.list import MultipleObjectTemplateResponseMixin,MultipleObjectMixin from django.views.generic.base import View @@ -268,6 +269,34 @@ def hodnoceniReseniView(request, pk, *args, **kwargs): return redirect(success_url) +class ResitelReseniView(DetailView): + model = m.Reseni + template_name = 'seminar/odevzdavatko/detail_resitele.html' + + def aktualni_hodnoceni(self): + self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) + result = [] + for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni): + result.append( + { + "problem": hodn.problem, + "body": hodn.body, + # "cislo_body": hodn.cislo_body, + } + ) + return result + + def get_context_data(self, **kw): + ctx = super().get_context_data(**kw) + hodnoceni = self.aktualni_hodnoceni() + if self.request.user not in self.reseni.resitele.all(): + raise PermissionDenied() + # ctx['poznamka'] = f.PoznamkaReseniForm(instance=self.reseni) + ctx["hodnoceni"] = hodnoceni + return ctx + + + class PrehledOdevzdanychReseni(ListView): model = m.Hodnoceni template_name = 'seminar/odevzdavatko/resitel_prehled.html'