Beispiel #1
0
    def get_form(self, obj):
        result_group_definition_id = request.args.get("result_group_definition_id")

        if result_group_definition_id is not None:
            try:
                result_group_definition_id = int(result_group_definition_id)
            except ValueError:
                result_group_definition_id = None

        if result_group_definition_id is None:
            select_form = SelectAddResultGroupForm()
            result_group_choices = get_result_group_choices()
            result_group_choices = add_empty_choice(result_group_choices)
            select_form.result_group_definition_id.choices = result_group_choices
            self.select_form = select_form

            if select_form.validate_on_submit():
                result_group_definition_id = select_form.result_group_definition_id.data

        if result_group_definition_id is not None:
            result_group_definition = ResultGroupDefinition.query.get_or_404(result_group_definition_id)
            obj.result_group_definition = result_group_definition
            obj.result_group_definition_id = result_group_definition.id  # needed for form
            return super(ResultGroupAddView, self).get_form(obj)
        else:
            return None
Beispiel #2
0
def get_unit_filter_choices(user):
    unit_choices = [(x.id, x.name) for x in get_unit_filters_for_user(user)]
    unit_choices = add_empty_choice(unit_choices)
    return unit_choices
Beispiel #3
0
def get_disease_group_filter_choices(user):
    disease_group_choices = [(x.id, x.name) for x in get_disease_group_filters_for_user(user)]
    disease_group_choices = add_empty_choice(disease_group_choices)
    return disease_group_choices