def add_country(self, country): self.meta.setdefault('countries', []) country = parse_country(country) if country is None: return if is_country_code(country) and country not in self.meta['countries']: self.meta['countries'].append(country) self.update_meta()
def parse_data(self, data): parsed = {f: [] for f in self.MULTI} for field, value in data.items(): if field in self.MULTI: for value in ensure_list(value): value = stringify(value) if value is None or value in parsed[field]: continue parsed[field].append(value) else: value = stringify(value) if field in ['country']: value = parse_country(value) if value is not None: parsed[field] = value return parsed
def add_country(self, country): country = parse_country(country) if country is None: return if is_country_code(country) and country not in self._countries: self._countries.append(country)
def normalize_value(self, value): return parse_country(value)
def clean(self, value, record, config): value = super(CountryProperty, self).clean(value, record, config) return parse_country(value) or value