Esempio n. 1
0
    def done(self, form_list, form_dict, **kwargs):
        if self.request.user.is_authenticated:
            user = self.request.user
        else:
            uid = form_dict['user'].save()
            user = User.objects.get(pk=uid)

        form_dict['info'].instance.event = self.request.event
        form_dict['info'].save()
        form_dict['info'].instance.speakers.add(user)
        sub = form_dict['info'].instance
        form_dict['profile'].user = user
        form_dict['profile'].save()
        if 'questions' in form_dict:
            for k, value in form_dict['questions'].cleaned_data.items():
                qid = k.split('_')[1]
                question = self.request.event.questions.get(pk=qid)
                answer = Answer(question=question, submission=sub)

                if question.variant == QuestionVariant.MULTIPLE:
                    answstr = ", ".join([str(o) for o in value])
                    answer.save()
                    answer.answer = answstr
                    answer.options.add(*value)
                elif question.variant == QuestionVariant.CHOICES:
                    answer.save()
                    answer.options.add(value)
                    answer.answer = value.answer
                else:
                    answer.answer = value
                answer.save()

        try:
            sub.event.ack_template.to_mail(
                user=user,
                event=self.request.event,
                context=template_context_from_submission(sub),
                skip_queue=True,
                locale=user.locale)
            if self.request.event.settings.mail_on_new_submission:
                MailTemplate(
                    event=self.request.event,
                    subject=_('[{event}] New submission!').format(
                        event=self.request.event.slug),
                    text=self.request.event.settings.mail_text_new_submission,
                ).to_mail(user=user,
                          event=self.request.event,
                          context=template_context_from_submission(sub),
                          skip_queue=True,
                          locale=self.request.event.locale)
        except SendMailException as e:
            logging.getLogger('').warning(str(e))
            messages.warning(self.request, phrases.cfp.submission_email_fail)

        sub.log_action('pretalx.submission.create', person=user)
        messages.success(self.request, phrases.cfp.submission_success)
        login(self.request, user)
        return redirect(
            reverse('cfp:event.user.submissions',
                    kwargs={'event': self.request.event.slug}))
Esempio n. 2
0
    def done(self, form_list, **kwargs):
        form_dict = kwargs.get('form_dict')
        if self.request.user.is_authenticated:
            user = self.request.user
        else:
            uid = form_dict['user'].save()
            user = User.objects.filter(pk=uid).first()
        if not user:
            raise ValidationError(
                _(
                    'There was an error with your user account. Please contact the organiser for further help.'
                )
            )

        form_dict['info'].instance.event = self.request.event
        form_dict['info'].save()
        form_dict['info'].instance.speakers.add(user)
        sub = form_dict['info'].instance
        form_dict['profile'].user = user
        form_dict['profile'].save()
        if 'questions' in form_dict:
            for k, value in form_dict['questions'].cleaned_data.items():
                qid = k.split('_')[1]
                self._handle_question_answer(sub, qid, value, user=user)

        try:
            sub.event.ack_template.to_mail(
                user=user,
                event=self.request.event,
                context=template_context_from_submission(sub),
                skip_queue=True,
                locale=user.locale,
            )
            if self.request.event.settings.mail_on_new_submission:
                MailTemplate(
                    event=self.request.event,
                    subject=_('New submission!').format(event=self.request.event.slug),
                    text=self.request.event.settings.mail_text_new_submission,
                ).to_mail(
                    user=self.request.event.email,
                    event=self.request.event,
                    context=template_context_from_submission(sub),
                    skip_queue=True,
                    locale=self.request.event.locale,
                )
        except SendMailException as exception:
            logging.getLogger('').warning(str(exception))
            messages.warning(self.request, phrases.cfp.submission_email_fail)

        sub.log_action('pretalx.submission.create', person=user)
        messages.success(self.request, phrases.cfp.submission_success)
        login(self.request, user, backend='django.contrib.auth.backends.ModelBackend')
        return redirect(
            reverse(
                'cfp:event.user.submissions', kwargs={'event': self.request.event.slug}
            )
        )
Esempio n. 3
0
    def done(self, request):
        # We are done, or at least we finished the last step. Time to check results.
        valid_steps = []
        for step in request.event.cfp_flow.steps:
            if step.is_applicable(request):
                if not step.is_completed(request):
                    return redirect(step.get_step_url(request))
                valid_steps.append(step)

        # We are done, or at least the data checks out. Time to save results.
        request.event.cfp_flow.steps_dict["user"].done(request)
        for step in valid_steps:
            if not step.identifier == "user":
                step.done(request)

        try:
            request.event.ack_template.to_mail(
                user=request.user,
                event=request.event,
                context=template_context_from_submission(request.submission),
                skip_queue=True,
                locale=request.user.locale,
                submission=request.submission,
                full_submission_content=True,
            )
            if request.event.settings.mail_on_new_submission:
                MailTemplate(
                    event=request.event,
                    subject=str(_("New proposal: {title}")).format(
                        title=request.submission.title),
                    text=request.event.settings.mail_text_new_submission,
                ).to_mail(
                    user=request.event.email,
                    event=request.event,
                    context=template_context_from_submission(
                        request.submission),
                    skip_queue=True,
                    locale=request.event.locale,
                )
        except SendMailException as exception:
            logging.getLogger("").warning(str(exception))
            messages.warning(request, phrases.cfp.submission_email_fail)

        return redirect(
            reverse("cfp:event.user.submissions",
                    kwargs={"event": request.event.slug}))
Esempio n. 4
0
    def reject(self, person=None, force=False, orga=True):
        self._set_state(SubmissionStates.REJECTED, force, person=person)
        self.log_action('pretalx.submission.reject', person=person, orga=True)

        for speaker in self.speakers.all():
            self.event.reject_template.to_mail(
                user=speaker,
                event=self.event,
                context=template_context_from_submission(self),
                locale=self.content_locale,
            )
Esempio n. 5
0
    def reject(self, person=None, force=False):
        self._set_state(SubmissionStates.REJECTED, force)
        self.log_action('pretalx.submission.reject', person=person, orga=True)

        from pretalx.schedule.models import TalkSlot
        TalkSlot.objects.filter(submission=self, schedule=self.event.wip_schedule).delete()

        for speaker in self.speakers.all():
            self.event.reject_template.to_mail(
                user=speaker, event=self.event, context=template_context_from_submission(self),
                locale=self.content_locale
            )
Esempio n. 6
0
    def accept(self, person=None, force=False):
        self._set_state(SubmissionStates.ACCEPTED, force)
        self.log_action('pretalx.submission.accept', person=person, orga=True)

        from pretalx.schedule.models import TalkSlot
        TalkSlot.objects.create(submission=self, schedule=self.event.wip_schedule, is_visible=True)

        for speaker in self.speakers.all():
            self.event.accept_template.to_mail(
                user=speaker, event=self.event, context=template_context_from_submission(self),
                locale=self.content_locale
            )
Esempio n. 7
0
    def accept(self, person=None, force=False, orga=True):
        previous = self.state
        self._set_state(SubmissionStates.ACCEPTED, force, person=person)
        self.log_action('pretalx.submission.accept', person=person, orga=True)

        if previous != SubmissionStates.CONFIRMED:
            for speaker in self.speakers.all():
                self.event.accept_template.to_mail(
                    user=speaker,
                    event=self.event,
                    context=template_context_from_submission(self),
                    locale=self.content_locale,
                )
Esempio n. 8
0
    def reject(self, person=None, force: bool = False, orga: bool = True):
        """Sets the submission's state to 'rejected' and creates a rejection
        :class:`~pretalx.mail.models.QueuedMail`."""
        self._set_state(SubmissionStates.REJECTED, force, person=person)
        self.log_action('pretalx.submission.reject', person=person, orga=True)

        for speaker in self.speakers.all():
            self.event.reject_template.to_mail(
                user=speaker,
                event=self.event,
                context=template_context_from_submission(self),
                locale=self.content_locale,
            )
Esempio n. 9
0
    def reject(self, person=None):
        self.state = SubmissionStates.REJECTED
        self.save(update_fields=['state'])
        self.log_action('pretalx.submission.reject', person=person, orga=True)

        from pretalx.schedule.models import TalkSlot
        TalkSlot.objects.filter(submission=self, schedule=self.event.wip_schedule).delete()

        for speaker in self.speakers.all():
            self.event.accept_template.to_mail(
                user=speaker, event=self.event, context=template_context_from_submission(self),
                locale=speaker.locale
            )
Esempio n. 10
0
    def accept(self, person=None, force=False, orga=True):
        previous = self.state
        self._set_state(SubmissionStates.ACCEPTED, force, person=person)
        self.log_action('pretalx.submission.accept', person=person, orga=True)

        from pretalx.schedule.models import TalkSlot
        TalkSlot.objects.update_or_create(submission=self, schedule=self.event.wip_schedule, defaults={'is_visible': True})

        if previous != SubmissionStates.CONFIRMED:
            for speaker in self.speakers.all():
                self.event.accept_template.to_mail(
                    user=speaker, event=self.event, context=template_context_from_submission(self),
                    locale=self.content_locale
                )
Esempio n. 11
0
    def send_state_mail(self):
        if self.state == SubmissionStates.ACCEPTED:
            template = self.event.accept_template
        elif self.state == SubmissionStates.REJECTED:
            template = self.event.reject_template
        else:
            return

        kwargs = {
            "event": self.event,
            "context": template_context_from_submission(self),
            "locale": self.content_locale,
        }
        for speaker in self.speakers.all():
            template.to_mail(user=speaker, **kwargs)
Esempio n. 12
0
    def accept(self, person=None, force=False):
        if self.state not in [SubmissionStates.SUBMITTED, SubmissionStates.REJECTED] and not force:
            raise SubmissionError(f'Submission must be submitted or rejected, not {self.state} to be accepted.')

        self.state = SubmissionStates.ACCEPTED
        self.save(update_fields=['state'])
        self.log_action('pretalx.submission.accept', person=person, orga=True)

        from pretalx.schedule.models import TalkSlot
        TalkSlot.objects.create(submission=self, schedule=self.event.wip_schedule)

        for speaker in self.speakers.all():
            self.event.accept_template.to_mail(
                user=speaker, event=self.event, context=template_context_from_submission(self),
                locale=speaker.locale
            )
Esempio n. 13
0
    def accept(self, person=None, force: bool = False, orga: bool = True):
        """Sets the submission's state to 'accepted'.

        Creates an acceptance :class:`~pretalx.mail.models.QueuedMail` unless
        the submission was previously confirmed."""
        previous = self.state
        self._set_state(SubmissionStates.ACCEPTED, force, person=person)
        self.log_action('pretalx.submission.accept', person=person, orga=True)

        if previous != SubmissionStates.CONFIRMED:
            for speaker in self.speakers.all():
                self.event.accept_template.to_mail(
                    user=speaker,
                    event=self.event,
                    context=template_context_from_submission(self),
                    locale=self.content_locale,
                )
Esempio n. 14
0
    def done(self, form_list, form_dict, **kwargs):
        if self.request.user.is_authenticated:
            user = self.request.user
        else:
            uid = form_dict['user'].save()
            user = User.objects.get(pk=uid)

        form_dict['info'].instance.event = self.request.event
        form_dict['info'].save()
        form_dict['info'].instance.speakers.add(user)
        sub = form_dict['info'].instance
        form_dict['profile'].user = user
        form_dict['profile'].save()
        sub.event.ack_template.to_mail(
            user=user, event=self.request.event, context=template_context_from_submission(sub),
            skip_queue=True, locale=user.locale
        )

        if 'questions' in form_dict:
            for k, value in form_dict['questions'].cleaned_data.items():
                qid = k.split('_')[1]
                question = Question.objects.get(pk=qid)
                answer = Answer(question=question, submission=sub)

                if question.variant == QuestionVariant.MULTIPLE:
                    answstr = ", ".join([str(o) for o in value])
                    answer.save()
                    answer.answer = answstr
                    answer.options.add(*value)
                elif question.variant == QuestionVariant.CHOICES:
                    answer.save()
                    answer.options.add(value)
                    answer.answer = value.answer
                else:
                    answer.answer = value
                answer.save()

        sub.log_action('pretalx.submission.create', person=user)
        messages.success(self.request, 'Your talk has been submitted successfully!')
        login(self.request, user)
        return redirect(reverse('cfp:event.user.submissions', kwargs={
            'event': self.request.event.slug
        }))
Esempio n. 15
0
    def done(self, form_list, **kwargs):
        form_dict = kwargs.get('form_dict')
        if self.request.user.is_authenticated:
            user = self.request.user
        else:
            uid = form_dict['user'].save()
            user = User.objects.filter(pk=uid).first()
        if not user or not user.is_active:
            raise ValidationError(
                _('There was an error when logging in. Please contact the organiser for further help.'
                  ), )

        form_dict['info'].instance.event = self.request.event
        form_dict['info'].save()
        form_dict['info'].instance.speakers.add(user)
        sub = form_dict['info'].instance
        form_dict['profile'].user = user
        form_dict['profile'].save()
        if 'questions' in form_dict:
            form_dict['questions'].speaker = user
            form_dict['questions'].submission = form_dict['info'].instance
            form_dict['questions'].save()

        try:
            sub.event.ack_template.to_mail(
                user=user,
                event=self.request.event,
                context=template_context_from_submission(sub),
                skip_queue=True,
                locale=user.locale,
                submission=sub,
                full_submission_content=True,
            )
            if self.request.event.settings.mail_on_new_submission:
                MailTemplate(
                    event=self.request.event,
                    subject=_('New submission!').format(
                        event=self.request.event.slug),
                    text=self.request.event.settings.mail_text_new_submission,
                ).to_mail(
                    user=self.request.event.email,
                    event=self.request.event,
                    context=template_context_from_submission(sub),
                    skip_queue=True,
                    locale=self.request.event.locale,
                )
            additional_speaker = form_dict['info'].cleaned_data.get(
                'additional_speaker').strip()
            if additional_speaker:
                sub.send_invite(to=[additional_speaker], _from=user)
        except SendMailException as exception:
            logging.getLogger('').warning(str(exception))
            messages.warning(self.request, phrases.cfp.submission_email_fail)

        if self.access_code:
            sub.access_code = self.access_code
            sub.save()
            self.access_code.redeemed += 1
            self.access_code.save()

        sub.log_action('pretalx.submission.create', person=user)
        messages.success(self.request, phrases.cfp.submission_success)
        login(self.request,
              user,
              backend='django.contrib.auth.backends.ModelBackend')
        return redirect(
            reverse('cfp:event.user.submissions',
                    kwargs={'event': self.request.event.slug}))