Example #1
0
    def __init__(self, project, data=None, is_datasender=False, datasender_name=''):
        super(SurveyResponseForm, self).__init__(project, data, is_datasender, datasender_name)

        for field in self.form_model.fields:
            if isinstance(field, UniqueIdField):
                self.fields[field.code] = SubjectQuestionFieldCreator(self.form_model).create(field)
            else:
                form_field = FormField().create(field)
                if data:
                    form_field.initial = data.get(field.code)
                self.fields[field.code] = form_field
Example #2
0
    def __init__(self, manager, project, questionnaire_form_model, data):
        super(EditSubmissionForm, self).__init__(data=data)
        self.form_model = questionnaire_form_model
        self.fields['form_code'] = CharField(
            widget=HiddenInput, initial=questionnaire_form_model.form_code)
        if questionnaire_form_model.entity_question is not None:
            entity_question = questionnaire_form_model.entity_question
            choices = EntityField(manager,
                                  project).create(entity_question,
                                                  project.entity_type)
            self.fields[entity_question.code] = choices.get(
                entity_question.code)
            self.short_code_question_code = questionnaire_form_model.entity_question.code

        for field in questionnaire_form_model.fields:
            if not field.is_entity_field:
                form_field = FormField().create(field)
                form_field.initial = data.get(field.code) if data.get(
                    field.code) is not None else data.get(field.code.lower())
                self.fields[field.code] = form_field