diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
| -rw-r--r-- | archaeological_warehouse/models.py | 17 | 
1 files changed, 16 insertions, 1 deletions
| diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index ecf33bb87..b51f33176 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -33,7 +33,8 @@ from django.template.defaultfilters import slugify  from ishtar_common.utils import ugettext_lazy as _, pgettext_lazy  from django.apps import apps -from ishtar_common.data_importer import post_importer_action +from ishtar_common.data_importer import post_importer_action, \ +    pre_importer_action  from ishtar_common.model_managers import ExternalIdManager, UUIDModelManager  from ishtar_common.models import Document, GeneralType, get_external_id, \      LightHistorizedItem, OwnPerms, Address, Person, post_save_cache, \ @@ -939,6 +940,20 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,      def natural_key(self):          return (self.uuid, ) +    @classmethod +    @pre_importer_action +    def import_get_location(cls, context, value): +        if context.get("container_type", None) and context.get( +                "reference", None): +            try: +                context["location"] = Warehouse.objects.get(external_id=value) +                return +            except Warehouse.DoesNotExist: +                pass +        for k in list(context.keys()): +            if k != "import_get_location": +                context.pop(k) +      def _generate_cached_label(self):          return self.precise_location | 
