|
@ -173,7 +173,9 @@ class ReseniProblemuView(MultipleObjectTemplateResponseMixin, MultipleObjectMixi |
|
|
|
|
|
|
|
|
def get_context_data(self, *args, **kwargs): |
|
|
def get_context_data(self, *args, **kwargs): |
|
|
ctx = super().get_context_data(*args, **kwargs) |
|
|
ctx = super().get_context_data(*args, **kwargs) |
|
|
# FIXME: Lepší by bylo předat groupby do template. |
|
|
# XXX: Předat groupby do template nejde: https://stackoverflow.com/questions/6906593/itertools-groupby-in-a-django-template |
|
|
|
|
|
# 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))} |
|
|
ctx['reseni_podle_deadlinu'] = {k: list(v) for k,v in groupby(ctx['object_list'], lambda r: deadline(r.cas_doruceni))} |
|
|
return ctx |
|
|
return ctx |
|
|
|
|
|
|
|
|