def _process(self): allow_reschedule_start = self.survey.state in (SurveyState.ready_to_open, SurveyState.active_and_clean, SurveyState.finished) form = ScheduleSurveyForm(obj=self._get_form_defaults(), survey=self.survey, allow_reschedule_start=allow_reschedule_start) if form.validate_on_submit(): if allow_reschedule_start: self.survey.start_dt = form.start_dt.data if getattr(form, 'resend_start_notification', False): self.survey.start_notification_sent = not form.resend_start_notification.data self.survey.end_dt = form.end_dt.data flash(_('Survey was scheduled'), 'success') logger.info('Survey %s scheduled by %s', self.survey, session.user) return jsonify_data(flash=False) disabled_fields = ('start_dt',) if not allow_reschedule_start else () return jsonify_form(form, submit=_('Schedule'), disabled_fields=disabled_fields)
def _process(self): allow_reschedule_start = self.survey.state in ( SurveyState.ready_to_open, SurveyState.active_and_clean, SurveyState.finished, ) form = ScheduleSurveyForm( obj=self._get_form_defaults(), survey=self.survey, allow_reschedule_start=allow_reschedule_start ) if form.validate_on_submit(): if allow_reschedule_start: self.survey.start_dt = form.start_dt.data if getattr(form, "resend_start_notification", False): self.survey.start_notification_sent = not form.resend_start_notification.data self.survey.end_dt = form.end_dt.data flash(_("Survey was scheduled"), "success") logger.info("Survey {} scheduled by {}".format(self.survey, session.user)) return jsonify_data(flash=False) disabled_fields = ("start_dt",) if not allow_reschedule_start else () return jsonify_template( "events/surveys/management/schedule_survey.html", form=form, disabled_fields=disabled_fields )