propose view (WIP)
This commit is contained in:
parent
05b57ccc1a
commit
f5dcf1a2d6
22
cfp/views.py
22
cfp/views.py
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue