예제 #1
0
 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')
예제 #2
0
 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')
예제 #3
0
 def _process(self):
     form = SectionForm(obj=FormDefaults(self.section))
     if form.validate_on_submit():
         old_title = self.section.title
         form.populate_obj(self.section)
         db.session.flush()
         flash(_('Section "{title}" updated').format(title=old_title), 'success')
         logger.info('Survey section {} modified by {}'.format(self.section, session.user))
         return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template('events/surveys/management/edit_survey_item.html', form=form)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 def _process(self):
     form = SectionForm(obj=FormDefaults(self.section))
     if form.validate_on_submit():
         old_title = self.section.title
         form.populate_obj(self.section)
         db.session.flush()
         if old_title:
             message = _('Section "{title}" updated').format(title=old_title)
         else:
             message = _('Standalone section updated')
         flash(message, 'success')
         logger.info('Survey section %s modified by %s', self.section, session.user)
         return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template('forms/form_common_fields_first.html', form=form)
예제 #7
0
 def _process(self):
     form = SectionForm(obj=FormDefaults(self.section))
     if form.validate_on_submit():
         old_title = self.section.title
         form.populate_obj(self.section)
         db.session.flush()
         if old_title:
             message = _('Section "{title}" updated').format(title=old_title)
         else:
             message = _('Standalone section updated')
         flash(message, 'success')
         logger.info('Survey section %s modified by %s', self.section, session.user)
         return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template('forms/form_common_fields_first.html', form=form)
예제 #8
0
 def _process(self):
     form = SectionForm(obj=FormDefaults(self.section))
     if form.validate_on_submit():
         old_title = self.section.title
         form.populate_obj(self.section)
         db.session.flush()
         flash(
             _('Section "{title}" updated').format(title=old_title),
             'success')
         logger.info('Survey section {} modified by {}'.format(
             self.section, session.user))
         return jsonify_data(
             questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template(
         'events/surveys/management/edit_survey_item.html', form=form)