def talk_proposal(request, event_slug, pk=None): event = Event.objects.filter(slug__iexact=event_slug).first() if not event: return handler404(request) if not event.talk_proposal_is_open: messages.error(request, _("The talk proposal is already closed or the event is not accepting proposals through this " "page. Please contact the Event Organization Team to submit it.")) return HttpResponseRedirect(reverse('index', args=(event_slug,))) errors = [] new_activity, new_proposal = None, None if pk: proposal = TalkProposal.objects.filter(pk=pk).first() if not proposal: return handler404(request) activity = proposal.activity else: activity = Activity(event=event) proposal = TalkProposal(activity=activity) activity_form = ActivityForm(request.POST or None, instance=activity) proposal_form = TalkProposalForm(request.POST or None, request.FILES or None, instance=proposal) forms = [activity_form, proposal_form] if request.POST: if activity_form.is_valid(): try: new_activity = activity_form.save() if proposal_form.is_valid(): new_proposal = proposal_form.save() new_proposal.activity = new_activity new_proposal.save() return HttpResponseRedirect(reverse('image_cropping', args=(event_slug, proposal.pk))) except Exception: pass if new_activity is not None: Activity.delete(new_activity) if new_proposal is not None: TalkProposal.delete(new_proposal) messages.error(request, _("The proposal couldn't be registered (check form errors)")) errors = get_forms_errors(forms) return render(request, 'activities/talks/proposal.html', update_event_info(event_slug, request, {'forms': forms, 'errors': errors, 'multipart': False}))
def talk_proposal(request, sede_url, pk=None): sede = Sede.objects.get(url__iexact=sede_url) if not sede.talk_proposal_is_open: messages.error(request, _( "The talk proposal is already close or the sede is not accepting proposals through this " "page. Please contact the Sede Organization Team to submit it.")) return HttpResponseRedirect(reverse('index', args=(sede_url,))) proposal = TalkProposal.objects.get(pk=pk) if pk else TalkProposal(sede=sede) form = TalkProposalForm(request.POST or None, request.FILES or None, instance=proposal) if request.POST: if form.is_valid(): proposal = form.save() return HttpResponseRedirect(reverse('image_cropping', args=(sede_url, proposal.pk))) messages.error(request, _("The proposal hasn't been registered successfully (check form errors)")) return render(request, 'talks/proposal.html', update_sede_info(sede_url, {'form': form}))
def talk_proposal(request, event_slug, pk=None): event = Event.objects.get(slug__iexact=event_slug) if not event.talk_proposal_is_open: messages.error(request, _("The talk proposal is already close or the event is not accepting proposals through this" "page. Please contact the Event Organization Team to submit it.")) return HttpResponseRedirect(reverse('index', args=(event_slug,))) errors = [] new_activity, new_proposal = None, None if pk: proposal = TalkProposal.objects.get(pk=pk) activity = proposal.activity else: activity = Activity(event=event) proposal = TalkProposal(activity=activity) activity_form = ActivityForm(request.POST or None, instance=activity) proposal_form = TalkProposalForm(request.POST or None, request.FILES or None, instance=proposal) forms = [activity_form, proposal_form] if request.POST: if activity_form.is_valid(): try: new_activity = activity_form.save() if proposal_form.is_valid(): new_proposal = proposal_form.save() new_proposal.activity = new_activity new_proposal.save() return HttpResponseRedirect(reverse('image_cropping', args=(event_slug, proposal.pk))) except Exception: pass if new_activity is not None: Activity.delete(new_activity) if new_proposal is not None: TalkProposal.delete(new_proposal) messages.error(request, _("The proposal couldn't be registered (check form errors)")) errors = get_forms_errors(forms) return render(request, 'activities/talks/proposal.html', update_event_info(event_slug, {'forms': forms, 'errors': errors, 'multipart': False}))