Browse Source

Pavlovy připomínky k mé předchozí úpravě

middleware_test
Jonas Havelka 3 years ago
parent
commit
95f8719fe7
  1. 4
      data/sitetree.json
  2. 9
      seminar/views/odevzdavatko.py

4
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",

9
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

Loading…
Cancel
Save