Oprava nahrání řešení (Chceme nastavovat v setup
u a ne v get
u)
This commit is contained in:
parent
24c790185e
commit
5b36650e6f
1 changed files with 7 additions and 3 deletions
|
@ -411,15 +411,19 @@ class NahrajReseniView(LoginRequiredMixin, CreateView):
|
|||
model = m.Reseni
|
||||
template_name = 'odevzdavatko/nahraj_reseni.html'
|
||||
form_class = f.NahrajReseniForm
|
||||
nadproblem: m.Problem
|
||||
|
||||
def setup(self, request, *args, **kwargs):
|
||||
super().setup(request, *args, **kwargs)
|
||||
nadproblem_id = self.kwargs["nadproblem_id"]
|
||||
self.nadproblem = get_object_or_404(m.Problem, id=nadproblem_id)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
# Zaříznutí nezadaných problémů
|
||||
nadproblem_id = self.kwargs["nadproblem_id"]
|
||||
self.nadproblem = get_object_or_404(m.Problem, id=nadproblem_id)
|
||||
if self.nadproblem.stav != m.Problem.STAV_ZADANY:
|
||||
raise PermissionDenied()
|
||||
|
||||
|
||||
|
||||
# Zaříznutí starých řešitelů:
|
||||
# FIXME: Je to tady dost naprasené, mělo by to asi být jinde…
|
||||
osoba = m.Osoba.objects.get(user=self.request.user)
|
||||
|
|
Loading…
Reference in a new issue