diff options
Diffstat (limited to 'archaeological_warehouse')
| -rw-r--r-- | archaeological_warehouse/models.py | 84 | 
1 files changed, 84 insertions, 0 deletions
| diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index fdd3a5e63..bea55be9b 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -26,6 +26,7 @@ from django.db.models.signals import post_save, post_delete  from django.template.defaultfilters import slugify  from django.utils.translation import ugettext_lazy as _ +from ishtar_common.data_importer import post_importer_action  from ishtar_common.utils import cached_label_changed  from ishtar_common.models import GeneralType, get_external_id, \ @@ -38,6 +39,8 @@ class WarehouseType(GeneralType):          verbose_name = _(u"Warehouse type")          verbose_name_plural = _(u"Warehouse types")          ordering = ('label',) + +  post_save.connect(post_save_cache, sender=WarehouseType)  post_delete.connect(post_save_cache, sender=WarehouseType) @@ -217,6 +220,8 @@ class WarehouseDivision(GeneralType):      class Meta:          verbose_name = _(u"Warehouse division type")          verbose_name_plural = _(u"Warehouse division types") + +  post_save.connect(post_save_cache, sender=WarehouseDivision)  post_delete.connect(post_save_cache, sender=WarehouseDivision) @@ -354,6 +359,48 @@ class Container(LightHistorizedItem, ImageModel):                  container=self).order_by('division__order')          )) +    def get_localisation(self, place): +        locas = self.get_localisations() +        if len(locas) < (place + 1): +            return "" +        return locas[place] + +    @property +    def localisation_1(self): +        return self.get_localisation(0) + +    @property +    def localisation_2(self): +        return self.get_localisation(1) + +    @property +    def localisation_3(self): +        return self.get_localisation(2) + +    @property +    def localisation_4(self): +        return self.get_localisation(3) + +    @property +    def localisation_5(self): +        return self.get_localisation(4) + +    @property +    def localisation_6(self): +        return self.get_localisation(5) + +    @property +    def localisation_7(self): +        return self.get_localisation(6) + +    @property +    def localisation_8(self): +        return self.get_localisation(7) + +    @property +    def localisation_9(self): +        return self.get_localisation(8) +      def set_localisation(self, place, value):          """          Set the reference for the localisation number "place" (starting from 0) @@ -379,6 +426,42 @@ class Container(LightHistorizedItem, ImageModel):          obj, created = ContainerLocalisation.objects.update_or_create(**dct)          return obj +    @post_importer_action +    def set_localisation_1(self, context, value): +        return self.set_localisation(0, value) + +    @post_importer_action +    def set_localisation_2(self, context, value): +        return self.set_localisation(1, value) + +    @post_importer_action +    def set_localisation_3(self, context, value): +        return self.set_localisation(2, value) + +    @post_importer_action +    def set_localisation_4(self, context, value): +        return self.set_localisation(3, value) + +    @post_importer_action +    def set_localisation_5(self, context, value): +        return self.set_localisation(4, value) + +    @post_importer_action +    def set_localisation_6(self, context, value): +        return self.set_localisation(5, value) + +    @post_importer_action +    def set_localisation_7(self, context, value): +        return self.set_localisation(6, value) + +    @post_importer_action +    def set_localisation_8(self, context, value): +        return self.set_localisation(7, value) + +    @post_importer_action +    def set_localisation_9(self, context, value): +        return self.set_localisation(8, value) +      @property      def divisions_lbl(self):          locas = [ @@ -430,6 +513,7 @@ class Container(LightHistorizedItem, ImageModel):          for loca in q.all():              loca.delete() +  post_save.connect(cached_label_changed, sender=Container) | 
