def _append_country_for_location_field(self, form_model, values, organization): location_field_code = get_location_field_code(form_model) if location_field_code is None: return values if location_field_code in values and values[location_field_code]: values[location_field_code] = get_country_appended_location(values[location_field_code], organization.country_name()) return values
def clean(self): location_field_code = get_location_field_code(self.form_model) if location_field_code is None: return self.cleaned_data for question_code, values in self.cleaned_data.items(): if question_code == location_field_code: self.cleaned_data[question_code] = get_country_appended_location(values, self.country) return self.cleaned_data
def test_should_return_None_if_location_field_is_not_present(self): form_model = self._get_form_model() form_model.add_field(self._get_text_field()) self.assertEqual(None, get_location_field_code(form_model))
def test_should_give_location_code(self): form_model = self._get_form_model() form_model.add_field(self._get_location_field()) self.assertEqual(LOCATION_TYPE_FIELD_CODE, get_location_field_code(form_model))