propose view (WIP)

This commit is contained in:
Élie Bouttier 2017-06-03 13:17:05 +02:00
parent 05b57ccc1a
commit f5dcf1a2d6
1 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,28 @@ class ProposeView(FormView):
template_name = 'cfp/propose.html'
success_url = reverse_lazy('propose-complete')
def propose(request):
TalkForm = modelform_factory(Talk)
ParticipantForm = modelform_factory(Participant)
talk_form = TalkForm(request.POST or None)
participant_form = ParticipantForm(request.POST or None)
forms = [talk_form, participant_form]
if request.method == 'POST' and all([form.is_valid() for form in forms]):
talk = talk_form.save(commit=False)
talk.site = get_current_site(request)
email = participant.cleaned_data['email']
try:
participant = Participant.objects.get(email=email)
except Participant.DoesNoExist:
participant = participant_form.save()
talk.participant = participant
talk.save()
return redirect(reverse('propose-complete'))
return render('cfp/propose.html', {
'talk_form': talk_form,
'participant_form': participant_form,
})
class CompleteView(TemplateView):
template_name = 'cfp/complete.html'