Esempio n. 1
0
 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()
Esempio n. 2
0
 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
Esempio n. 3
0
 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)
Esempio n. 4
0
 def normalize_value(self, value):
     return parse_country(value)
Esempio n. 5
0
 def clean(self, value, record, config):
     value = super(CountryProperty, self).clean(value, record, config)
     return parse_country(value) or value