From 205aa0b900cf3fe9fb80cbc001ccfcb544860bb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 19 Jun 2023 20:24:19 +0200 Subject: [PATCH] =?UTF-8?q?V=20NahrajReseniView=20z=20nadprobl=C3=A9mu=20u?= =?UTF-8?q?d=C4=9Blat=20property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odevzdavatko/views.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index e7d362e0..667f74aa 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -415,8 +415,8 @@ class NahrajReseniView(LoginRequiredMixin, CreateView): def get(self, request, *args, **kwargs): # Zaříznutí nezadaných problémů nadproblem_id = self.kwargs["nadproblem_id"] - nadproblem = get_object_or_404(m.Problem, id=nadproblem_id) - if nadproblem.stav != "zadany": + self.nadproblem = get_object_or_404(m.Problem, id=nadproblem_id) + if self.nadproblem.stav != "zadany": raise PermissionDenied() @@ -433,10 +433,10 @@ class NahrajReseniView(LoginRequiredMixin, CreateView): return super().get(request, *args, **kwargs) def get_initial(self): - nadproblem_id = self.kwargs["nadproblem_id"] + nadproblem_id = self.nadproblem.id return { "nadproblem_id": nadproblem_id, - "problem": [] if m.Problem.objects.filter(stav=m.Problem.STAV_ZADANY, nadproblem__id=nadproblem_id) else nadproblem_id + "problem": [] if self.nadproblem.podproblem.filter(stav=m.Problem.STAV_ZADANY).exists() else nadproblem_id } @@ -447,8 +447,8 @@ class NahrajReseniView(LoginRequiredMixin, CreateView): else: data['prilohy'] = f.ReseniSPrilohamiFormSet() - data["nadproblem_id"] = self.kwargs["nadproblem_id"] - data["nadproblem"] = get_object_or_404(m.Problem, id=self.kwargs["nadproblem_id"]) + data["nadproblem_id"] = self.nadproblem.id + data["nadproblem"] = get_object_or_404(m.Problem, id=self.nadproblem.id) return data # FIXME prepsat tak, aby form_valid se volalo jen tehdy, kdyz je form i formset validni