def get_csv_values(self, field_name, values, translated=True): if not isinstance(values, list): values = split_data(values) if not translated: return values choices = self._dict_choices(field_name) return OrderedDict([(c, choices.get(c, c)) for c in values])
def get_csv_values(self, field_name, values, translated=True): if not isinstance(values, list): values = split_data(values) if not translated: return values choices = { (choice[0] if isinstance(choice, tuple) else choice): (choice[1] if isinstance(choice, tuple) else _(choice)) for choice in getattr( self, '{name}_CHOICES'.format(name=field_name.upper()), []) } return OrderedDict([(c, choices.get(c, c)) for c in values])
def get_cached_csv(self, field_name, value): if value is None: return [] values = split_data(value) map_method = getattr(self, u'cached_{}_map'.format(field_name), None) return [map_method(i) for i in values] if map_method else values