diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
| -rw-r--r-- | archaeological_warehouse/models.py | 22 | 
1 files changed, 15 insertions, 7 deletions
| diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index b1b6467ae..a40bfd321 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -30,7 +30,7 @@ from django.utils.translation import ugettext_lazy as _, pgettext_lazy, \  from ishtar_common.data_importer import post_importer_action  from ishtar_common.models import Document, GeneralType, get_external_id, \      LightHistorizedItem, OwnPerms, Address, Person, post_save_cache, \ -    ImageModel, DashboardFormItem, ExternalIdManager +    ImageModel, DashboardFormItem, ExternalIdManager, ShortMenuItem  from ishtar_common.utils import cached_label_changed @@ -45,7 +45,8 @@ post_save.connect(post_save_cache, sender=WarehouseType)  post_delete.connect(post_save_cache, sender=WarehouseType) -class Warehouse(Address, DashboardFormItem, OwnPerms): +class Warehouse(Address, DashboardFormItem, OwnPerms, +                ShortMenuItem):      SLUG = 'warehouse'      SHOW_URL = 'show-warehouse'      TABLE_COLS = ['name', 'warehouse_type'] @@ -124,7 +125,12 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):      @classmethod      def get_query_owns(cls, ishtaruser): -        return Q(person_in_charge__ishtaruser=ishtaruser) +        return cls._construct_query_own( +            '', cls._get_query_owns_dicts(ishtaruser)) + +    @classmethod +    def _get_query_owns_dicts(cls, ishtaruser): +        return [{'person_in_charge__ishtaruser': ishtaruser}]      @property      def number_of_finds(self): @@ -334,7 +340,7 @@ class Container(LightHistorizedItem, ImageModel):          'cached_division': _(u"Precise localisation"),          'container_type__label': _(u"Type")      } -    CACHED_LABELS = ['cached_label', 'cached_location', 'cached_division'] +    CACHED_LABELS = ['cached_division', 'cached_label', 'cached_location', ]      # alternative names of fields for searches      ALT_NAMES = { @@ -399,8 +405,7 @@ class Container(LightHistorizedItem, ImageModel):          )      def __unicode__(self): -        lbl = u"{} ({})".format(self.reference, self.container_type) -        return lbl +        return self.cached_label      def natural_key(self):          return (self.external_id, ) @@ -444,7 +449,10 @@ class Container(LightHistorizedItem, ImageModel):      @property      def precise_location(self): -        return self.location.name + u" - " + (self.cached_division or u"") +        location = self.location.name +        if self.cached_division: +            location += u" " + self.cached_division +        return location      def get_localisations(self):          """ | 
