summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-04 17:59:11 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-09-04 17:59:11 +0200
commitee0fa273d738a15b9d371ccfc564554035de4480 (patch)
tree4502979030dd8a0cc8f89831d6027e44d609e014
parent9ebbbb4aeb5ee9e99dacb23b0393a642a56f5715 (diff)
downloadIshtar-ee0fa273d738a15b9d371ccfc564554035de4480.tar.bz2
Ishtar-ee0fa273d738a15b9d371ccfc564554035de4480.zip
Operation types: fix get tuples
-rw-r--r--ishtar_common/models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index c6643100f..a4fe5af7f 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -522,7 +522,7 @@ class GeneralType(Cached, models.Model):
return u""
@classmethod
- def _get_initial_types(cls, initial, type_pks):
+ def _get_initial_types(cls, initial, type_pks, instance=False):
new_vals = []
if not initial:
return []
@@ -537,7 +537,10 @@ class GeneralType(Cached, models.Model):
continue
try:
extra_type = cls.objects.get(pk=pk)
- new_vals.append((extra_type.pk, unicode(extra_type)))
+ if instance:
+ new_vals.append(extra_type)
+ else:
+ new_vals.append((extra_type.pk, unicode(extra_type)))
except cls.DoesNotExist:
continue
return new_vals
@@ -2471,7 +2474,8 @@ class OperationType(GeneralType):
items = items.exclude(txt_idx__in=exclude)
current_preventive, current_lst = None, None
item_list = list(items.order_by(*cls._meta.ordering).all())
- new_vals = cls._get_initial_types(initial, [i.pk for i in item_list])
+ new_vals = cls._get_initial_types(initial, [i.pk for i in item_list],
+ instance=True)
item_list += new_vals
for item in item_list:
if not current_lst or item.preventive != current_preventive: