summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-12-04 12:59:54 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:22 +0100
commit51738d20be48b9dba0ab001fa740d37914c85742 (patch)
tree0355de3682bea1a70e9e953682bf99be6d99be69 /ishtar_common
parentd992bb445b8ceea253fec86a45cc11a736cfa876 (diff)
downloadIshtar-51738d20be48b9dba0ab001fa740d37914c85742.tar.bz2
Ishtar-51738d20be48b9dba0ab001fa740d37914c85742.zip
File: Quick add admin act
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py17
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