From caa6c616328807b1fb397de75c54e271bad38c87 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 24 Jul 2014 20:49:46 +0200 Subject: New sorting and displaying rules in shortcut menu (refs #1562) --- archaeological_files/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'archaeological_files') diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 04a723b82..bbced9a59 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -195,7 +195,9 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): if not cache_key: cache_key, val = get_cache(self.__class__, [self.pk, 'has_adminact']) - has_adminact = self.administrative_act.count() + has_adminact = self.administrative_act.exclude( + act_type__txt_idx='a_receipt').count() \ + or self.operations.count() cache.set(cache_key, has_adminact, settings.CACHE_TIMEOUT) return has_adminact @@ -225,8 +227,8 @@ class File(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): @classmethod def get_owns(cls, user): owns = super(File, cls).get_owns(user) - return sorted(owns.all(), key=lambda x:(x.has_adminact, - x.delay_date)) + return sorted(owns.all(), key=lambda x:(x.name, -x.year, + x.numeric_reference)) @classmethod def get_years(cls): -- cgit v1.2.3