Zprovozněno vložení řešení
This commit is contained in:
parent
523a3ef9fb
commit
82e81c602a
2 changed files with 17 additions and 4 deletions
|
@ -274,9 +274,9 @@ class VlozReseniForm(forms.Form):
|
||||||
#TODO body do cisla
|
#TODO body do cisla
|
||||||
#TODO prilohy
|
#TODO prilohy
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
##def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
## super().__init__(*args, **kwargs)
|
||||||
#self.fields['favorite_color'] = forms.ChoiceField(choices=[(color.id, color.name) for color in Resitel.objects.all()])
|
## #self.fields['favorite_color'] = forms.ChoiceField(choices=[(color.id, color.name) for color in Resitel.objects.all()])
|
||||||
|
|
||||||
class NahrajReseniForm(forms.ModelForm):
|
class NahrajReseniForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -1026,7 +1026,20 @@ class ResitelView(LoginRequiredMixin,generic.DetailView):
|
||||||
class AddSolutionView(LoginRequiredMixin, FormView):
|
class AddSolutionView(LoginRequiredMixin, FormView):
|
||||||
template_name = 'seminar/org/vloz_reseni.html'
|
template_name = 'seminar/org/vloz_reseni.html'
|
||||||
form_class = f.VlozReseniForm
|
form_class = f.VlozReseniForm
|
||||||
success_url = '/'
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
data = form.cleaned_data
|
||||||
|
nove_reseni = m.Reseni.objects.create(
|
||||||
|
cas_doruceni=data['cas_doruceni'],
|
||||||
|
forma=data['forma'],
|
||||||
|
poznamka=data['poznamka'],
|
||||||
|
)
|
||||||
|
nove_reseni.resitele.add(data['resitel'])
|
||||||
|
nove_reseni.problem.add(data['problem'])
|
||||||
|
nove_reseni.save()
|
||||||
|
# Chtěl jsem, aby bylo vidět, že se to uložilo, tak přesměrovávám na profil.
|
||||||
|
return redirect(reverse('profil'))
|
||||||
|
|
||||||
|
|
||||||
class NahrajReseniView(LoginRequiredMixin, CreateView):
|
class NahrajReseniView(LoginRequiredMixin, CreateView):
|
||||||
model = s.Reseni
|
model = s.Reseni
|
||||||
|
|
Loading…
Reference in a new issue