diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2014-07-24 20:49:46 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2014-07-24 20:49:46 +0200 |
commit | caa6c616328807b1fb397de75c54e271bad38c87 (patch) | |
tree | ae1c3c70b8bf6f324e420d125603f7b710ed4098 | |
parent | b20d8d8174e061eeb8447f6346b0aced164fbac7 (diff) | |
download | Ishtar-caa6c616328807b1fb397de75c54e271bad38c87.tar.bz2 Ishtar-caa6c616328807b1fb397de75c54e271bad38c87.zip |
New sorting and displaying rules in shortcut menu (refs #1562)
-rw-r--r-- | archaeological_files/models.py | 8 | ||||
-rw-r--r-- | archaeological_operations/models.py | 4 |
2 files changed, 8 insertions, 4 deletions
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): diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index a3f61f713..2c148366b 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -229,7 +229,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem): def get_owns(cls, user): owns = super(Operation, cls).get_owns(user) #owns = owns.annotate(null_count=Count('operation_code')) - return owns.order_by("-year", "operation_code") + return owns.order_by("common_name", "-year", "operation_code") def __unicode__(self): if self.cached_label: @@ -413,6 +413,8 @@ def operation_post_save(sender, **kwargs): operation.fnap_financing = fnap_percent operation.save() cached_label_changed(sender, **kwargs) + if operation.associated_file: + operation.associated_file.update_short_menu_class() post_save.connect(operation_post_save, sender=Operation) class OperationByDepartment(models.Model): |