From 95f8719fe7d7b07029132d928889a796fdc94a51 Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Fri, 17 Sep 2021 22:43:27 +0200 Subject: [PATCH] =?UTF-8?q?Pavlovy=20p=C5=99ipom=C3=ADnky=20k=20m=C3=A9=20?= =?UTF-8?q?p=C5=99edchoz=C3=AD=20=C3=BAprav=C4=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/sitetree.json | 4 ++-- seminar/views/odevzdavatko.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/data/sitetree.json b/data/sitetree.json index 3e80e39d..5702031a 100644 --- a/data/sitetree.json +++ b/data/sitetree.json @@ -970,9 +970,9 @@ "insitetree": true, "parent": 37, "sort_order": 50, - "title": "Detail řešení {{ reseni_id }}", + "title": "Detail řešení {{ reseni.id }}", "tree": 1, - "url": "odevzdavatko_detail_reseni reseni_id", + "url": "odevzdavatko_detail_reseni reseni.id", "urlaspattern": true }, "model": "sitetree.treeitem", diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index e3a94110..224acbd2 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -188,10 +188,6 @@ class ReseniProblemuView(MultipleObjectTemplateResponseMixin, MultipleObjectMixi jedine_reseni = self.object_list.first() return redirect(reverse("odevzdavatko_detail_reseni", kwargs={"pk": jedine_reseni.id})) context = self.get_context_data() - - context["resitel_id"] = self.kwargs['resitel'] - context["problem_id"] = self.kwargs['problem'] - return self.render_to_response(context) def get_context_data(self, *args, **kwargs): @@ -200,6 +196,10 @@ class ReseniProblemuView(MultipleObjectTemplateResponseMixin, MultipleObjectMixi # Django má {% regroup %}, ale ten potřebuje, aby klíč byl atribut položky: https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#regroup # Takže rozbalíme groupby do slovníku klíč → seznam sami (dictionary comphrehension) ctx['reseni_podle_deadlinu'] = {k: list(v) for k,v in groupby(ctx['object_list'], lambda r: deadline(r.cas_doruceni))} + + # Pro sitetree: + ctx["resitel_id"] = self.kwargs['resitel'] + ctx["problem_id"] = self.kwargs['problem'] return ctx ## XXX: https://docs.djangoproject.com/en/3.1/topics/class-based-views/mixins/#avoid-anything-more-complex @@ -223,7 +223,6 @@ class DetailReseniView(DetailView): ctx['form'] = f.OhodnoceniReseniFormSet( initial = self.aktualni_hodnoceni() ) - ctx['reseni_id'] = self.object.id return ctx