|
|
@ -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 |
|
|
|