diff --git a/src/pretalx/cfp/flow.py b/src/pretalx/cfp/flow.py index 1ff293c50..1632a2d80 100644 --- a/src/pretalx/cfp/flow.py +++ b/src/pretalx/cfp/flow.py @@ -19,6 +19,9 @@ from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ from django.views.generic.base import TemplateResponseMixin + +from django_context_decorator import context + from i18nfield.strings import LazyI18nString from i18nfield.utils import I18nJSONEncoder @@ -306,6 +309,7 @@ class InfoStep(GenericFlowStep, FormFlowStep): identifier = "info" icon = "paper-plane" form_class = InfoForm + template_name = "cfp/event/submission_info.html" priority = 0 @property @@ -339,12 +343,26 @@ def get_form_initial(self): result[field] = obj return result + @context + def questions_form(self): + return QuestionsForm( + data=self.request.POST if self.request.method == "POST" else None, + files=self.request.FILES if self.request.method == "POST" else None, + event=self.request.event, + speaker=self.request.user, + target="submission", + ) + def done(self, request, draft=False): self.request = request form = self.get_form(from_storage=True) + form.speaker = request.user form.instance.event = self.event - form.save() + form.is_valid() submission = form.instance + form.submission = submission + form.save() + submission.speakers.add(request.user) if draft: submission.state = SubmissionStates.DRAFT @@ -383,6 +401,12 @@ def done(self, request, draft=False): access_code.save() request.submission = submission + self.request = request + + qform = self.questions_form() + if qform.is_valid(): + qform.submission = self.request.submission + qform.save() class QuestionsStep(GenericFlowStep, FormFlowStep): @@ -537,16 +561,31 @@ def get_context_data(self, **kwargs): result["gravatar_parameter"] = User(email=email).gravatar_parameter return result + @context + def questions_form(self): + return QuestionsForm( + data=self.request.POST if self.request.method == "POST" else None, + files=self.request.FILES if self.request.method == "POST" else None, + event=self.request.event, + speaker=self.request.user, + target="speaker", + ) + def done(self, request, draft=False): form = self.get_form(from_storage=True) form.is_valid() form.user = request.user form.save() + self.request = request + + qform = self.questions_form() + if qform.is_valid(): + qform.submission = self.request.submission + qform.save() DEFAULT_STEPS = ( InfoStep, - QuestionsStep, UserStep, ProfileStep, ) diff --git a/src/pretalx/cfp/templates/cfp/event/submission_info.html b/src/pretalx/cfp/templates/cfp/event/submission_info.html new file mode 100644 index 000000000..a4b56d0cb --- /dev/null +++ b/src/pretalx/cfp/templates/cfp/event/submission_info.html @@ -0,0 +1,22 @@ +{% extends "cfp/event/submission_base.html" %} +{% load bootstrap4 %} +{% load i18n %} +{% load orga_edit_link %} +{% load rich_text %} +{% load rules %} + +{% block inner %} +
+ {{ text|rich_text }} +
+ SUBMISSION INFO + {% for field in form %} + {% bootstrap_field field layout='event' %} + {% endfor %} + {% if questions_form %}{% bootstrap_form questions_form layout='event' %}{% endif %} +{% endblock %} diff --git a/src/pretalx/cfp/templates/cfp/event/submission_profile.html b/src/pretalx/cfp/templates/cfp/event/submission_profile.html index 7141633a4..f17ea9930 100644 --- a/src/pretalx/cfp/templates/cfp/event/submission_profile.html +++ b/src/pretalx/cfp/templates/cfp/event/submission_profile.html @@ -24,6 +24,7 @@