def _import_section(self, data): self._remove_false_values(data) form = SectionForm(formdata=MultiDict(data.items()), csrf_enabled=False) if form.validate(): section = add_survey_section(self.survey, form.data) for item in data['content']: self._import_section_item(section, item) else: raise ValueError('Invalid section')
def _process(self): form = SectionForm() if form.validate_on_submit(): section = add_survey_section(self.survey, form.data) if section.title: message = _('Section "{title}" added').format(title=section.title) else: message = _('Standalone section added') flash(message, 'success') return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey)) return jsonify_template('forms/form_common_fields_first.html', form=form)