summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-29 17:33:45 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-01-29 17:33:45 +0100
commit478befbbf1705b8547f8e88a4b5822d3bad52200 (patch)
treedd6c2f8bff2ffb12c210f13090ecf845ef182560 /archaeological_finds
parent019f483daeb9fca526ef5f46fda650f01c551fc0 (diff)
downloadIshtar-478befbbf1705b8547f8e88a4b5822d3bad52200.tar.bz2
Ishtar-478befbbf1705b8547f8e88a4b5822d3bad52200.zip
Fix performance issues for shortcut menu
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/models_finds.py11
-rw-r--r--archaeological_finds/models_treatments.py21
2 files changed, 16 insertions, 16 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index e8b6135a8..588edb5cf 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -687,18 +687,17 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
Q(history_creator=user)
@classmethod
- def get_owns(cls, user, menu_filtr=None, limit=None):
+ def get_owns(cls, user, menu_filtr=None, limit=None,
+ values=None, get_short_menu_class=None):
replace_query = None
if menu_filtr and 'contextrecord' in menu_filtr:
replace_query = Q(
base_finds__context_record=menu_filtr['contextrecord']
)
owns = super(Find, cls).get_owns(
- user, replace_query=replace_query,
- limit=limit)
- return sorted(
- owns, key=lambda x: x.cached_label
- if hasattr(x, 'cached_label') else unicode(x))
+ user, replace_query=replace_query, limit=limit, values=values,
+ get_short_menu_class=get_short_menu_class)
+ return cls._return_get_owns(owns, values, get_short_menu_class)
def _generate_cached_label(self):
return unicode(self)
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index d8d51e28c..e94d1c272 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -171,7 +171,8 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
& Q(end_date__isnull=True)
@classmethod
- def get_owns(cls, user, menu_filtr=None, limit=None):
+ def get_owns(cls, user, menu_filtr=None, limit=None, values=None,
+ get_short_menu_class=None):
replace_query = None
if menu_filtr:
if 'treatmentfile' in menu_filtr:
@@ -184,10 +185,9 @@ class Treatment(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):
else:
replace_query = q
owns = super(Treatment, cls).get_owns(
- user, replace_query=replace_query, limit=limit)
- return sorted(
- owns, key=lambda x: x.cached_label
- if hasattr(x, 'cached_label') else unicode(x))
+ user, replace_query=replace_query, limit=limit,
+ values=values, get_short_menu_class=get_short_menu_class)
+ return cls._return_get_owns(owns, values, get_short_menu_class)
def get_query_operations(self):
return Operation.objects.filter(
@@ -531,11 +531,12 @@ class TreatmentFile(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
'name') if getattr(self, attr)])
@classmethod
- def get_owns(cls, user, menu_filtr=None, limit=None):
- owns = super(TreatmentFile, cls).get_owns(user, limit=limit)
- return sorted(
- owns, key=lambda x: x.cached_label
- if hasattr(x, 'cached_label') else unicode(x))
+ def get_owns(cls, user, menu_filtr=None, limit=None, values=None,
+ get_short_menu_class=None):
+ owns = super(TreatmentFile, cls).get_owns(
+ user, limit=limit, values=values,
+ get_short_menu_class=get_short_menu_class)
+ return cls._return_get_owns(owns, values, get_short_menu_class)
def _generate_cached_label(self):
items = [unicode(getattr(self, k))