diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c7406acfa..ac3755e13 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -156,11 +156,7 @@ class ValueGetter(object): def _get_values_update_sub_filter(self, filtr, prefix): if not filtr: return - new_filtr = [] - for k in filtr: - if k.startswith(prefix): - new_filtr.append(k[len(prefix):]) - return new_filtr + return [k[len(prefix):] for k in filtr if k.startswith(prefix)] def get_values(self, prefix='', no_values=False, filtr=None, **kwargs): if not prefix: @@ -190,16 +186,13 @@ class ValueGetter(object): values.update(self._get_values_documents(prefix=prefix, filtr=filtr)) for extra_field in self.GET_VALUES_EXTRA: values[prefix + extra_field] = getattr(self, extra_field) or '' - for key in values.keys(): - val = values[key] + for key, val in values.items(): if val is None: val = '' elif (key in self.GET_VALUES_EXTRA_TYPES or "type" in key) and ( val.__class__.__name__.split('.')[0] == 'ManyRelatedManager'): val = " ; ".join([str(v) for v in val.all()]) - elif isinstance(val, (tuple, list, dict)): - pass - else: + elif not isinstance(val, (tuple, list, dict)): val = str(val) if val.endswith('.None'): val = '' @@ -208,10 +201,10 @@ class ValueGetter(object): # do not provide KEYS and VALUES for sub-items return values value_list = [] - for key in values.keys(): + for key, value_ in values.items(): if key in ('KEYS', 'VALUES'): continue - value_list.append((key, str(values[key]))) + value_list.append((key, str(value_))) for global_var in GlobalVar.objects.all(): values[global_var.slug] = global_var.value or "" return values |