diff options
Diffstat (limited to 'archaeological_warehouse/models.py')
| -rw-r--r-- | archaeological_warehouse/models.py | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 565b64af2..04936d7a5 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -821,12 +821,12 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,          return self.location._get_base_image_path() + "/" + self.external_id      @classmethod -    def _change_parent_location(cls, parent): +    def _change_child_location(cls, parent):          for child in cls.objects.filter(parent=parent).all():              if child.location != parent.location:                  child.location = parent.location                  child.save() -            cls._change_parent_location(child) +            cls._change_child_location(child)      def merge(self, item, keep_old=False, exclude_fields=None):          # merge child containers @@ -844,7 +844,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,              else:                  child.parent = self                  child.save() -        self._change_parent_location(self) +        self._change_child_location(self)          super(Container, self).merge(item, keep_old=keep_old,                                       exclude_fields=exclude_fields) @@ -980,7 +980,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,              return          # modify existing -        current_localisations = self.get_localisations() +        ## first localisation is the warehouse +        current_localisations = list(self.get_localisations())[1:]          current_localisation, current_parent = None, None          for loca in current_localisations:              if loca.container_type == current_container_type: @@ -1143,7 +1144,7 @@ class Container(DocumentItem, Merge, LightHistorizedItem, QRCodeItem, GeoItem,      def save(self, *args, **kwargs):          self.pre_save()          super(Container, self).save(*args, **kwargs) -        self._change_parent_location(self) +        self._change_child_location(self)          updated = False          if not self.index: | 
