diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-01-24 13:08:31 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:23 +0100 | 
| commit | caf88fbf599a490b9dff1bc2668f0e7d62723dc8 (patch) | |
| tree | 9bf8aa54baef10982d2919f2bd0c872c5e34fd12 /archaeological_warehouse/models.py | |
| parent | 8d7ed2a8208a1d3422e4827a35fa7d6cb7f59cee (diff) | |
| download | Ishtar-caf88fbf599a490b9dff1bc2668f0e7d62723dc8.tar.bz2 Ishtar-caf88fbf599a490b9dff1bc2668f0e7d62723dc8.zip  | |
Container: prevent parent association to himself
Diffstat (limited to 'archaeological_warehouse/models.py')
| -rw-r--r-- | archaeological_warehouse/models.py | 6 | 
1 files changed, 5 insertions, 1 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 5d06cefda..e67fe2bd2 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1357,6 +1357,8 @@ class Container(DocumentItem, Merge, LightHistorizedItem,          return actions      def pre_save(self): +        if self.parent == self: +            self.parent = None          if not self.collection_id and not self.collection:              if self.location_id:                  self.collection_id = self.location_id @@ -1431,10 +1433,11 @@ class Container(DocumentItem, Merge, LightHistorizedItem,  def container_post_save(sender, **kwargs):      cached_label_and_geo_changed(sender=sender, **kwargs) +    #TODO: to be deleted??? +    """      if not kwargs.get('instance'):          return      instance = kwargs.get('instance') -    #TODO: to be deleted???      for loca in ContainerLocalisation.objects.filter(              container=instance).exclude(              division__warehouse=instance.location).all(): @@ -1446,6 +1449,7 @@ def container_post_save(sender, **kwargs):              continue          loca.division = q.all()[0]          loca.save() +    """  def container_pre_delete(sender, **kwargs):  | 
