Example #1
0
 def _process(self):
     form = TextForm()
     if form.validate_on_submit():
         add_survey_text(self.section, form.data)
         flash(_('Text item added'), 'success')
         return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template('forms/form_common_fields_first.html', form=form)
Example #2
0
 def _process(self):
     form = TextForm()
     if form.validate_on_submit():
         add_survey_text(self.section, form.data)
         flash(_('Text item added'), 'success')
         return jsonify_data(questionnaire=_render_questionnaire_preview(self.survey))
     return jsonify_template('forms/form_common_fields_first.html', form=form)
Example #3
0
 def _import_section_item(self, section, data):
     self._remove_false_values(data)
     if data['type'] == 'text':
         form = TextForm(formdata=MultiDict(data.items()), csrf_enabled=False)
         if form.validate():
             add_survey_text(section, form.data)
         else:
             raise ValueError('Invalid text item')
     elif data['type'] == 'question':
         for key, value in data['field_data'].iteritems():
             if value is not None:
                 data[key] = value
         field_cls = get_field_types()[data['field_type']]
         data = field_cls.process_imported_data(data)
         form = field_cls.create_config_form(formdata=MultiDict(data.items()), csrf_enabled=False)
         if not form.validate():
             raise ValueError('Invalid question')
         add_survey_question(section, field_cls, form.data)
Example #4
0
 def _import_section_item(self, section, data):
     self._remove_false_values(data)
     if data['type'] == 'text':
         form = TextForm(formdata=MultiDict(data.items()), csrf_enabled=False)
         if form.validate():
             add_survey_text(section, form.data)
         else:
             raise ValueError('Invalid text item')
     elif data['type'] == 'question':
         for key, value in data['field_data'].iteritems():
             if value is not None:
                 data[key] = value
         field_cls = get_field_types()[data['field_type']]
         data = field_cls.process_imported_data(data)
         form = field_cls.create_config_form(formdata=MultiDict(data.items()), csrf_enabled=False)
         if not form.validate():
             raise ValueError('Invalid question')
         add_survey_question(section, field_cls, form.data)