summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-01 17:18:33 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-13 18:26:03 +0200
commit3a8aa349b06129c4a8f591d56147ce0c97d4d9c5 (patch)
treecf9e060d38c62d422684f0de85239822eafed2df /archaeological_operations/models.py
parentdd2e367dde3d8df4fdfbc10b8f0d87607b160ef6 (diff)
downloadIshtar-3a8aa349b06129c4a8f591d56147ce0c97d4d9c5.tar.bz2
Ishtar-3a8aa349b06129c4a8f591d56147ce0c97d4d9c5.zip
Fix clean parcel script
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 1a534af7a..c9244ca48 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -1566,6 +1566,20 @@ class Parcel(LightHistorizedItem):
self.operation = None
self.save()
+ def clean_orphan(self):
+ """
+ Remove when the parcel is linked to nothing
+ """
+ if self.operation or self.associated_file:
+ return
+ if self.context_record.count():
+ # trying to restore a lost parcel
+ self.operation = self.context_record.all()[0].operation
+ self.skip_history_when_saving = True
+ self.save()
+ elif self.id:
+ self.delete()
+
def parcel_post_save(sender, **kwargs):
if not kwargs['instance']:
@@ -1576,23 +1590,6 @@ def parcel_post_save(sender, **kwargs):
updated = False
- """
- # remove when the parcel is linked to nothing
- # problematic in wizards
- # TODO: add admin action
- if not getattr(parcel, '_updated_id', None) and not created \
- and not parcel.operation and not parcel.associated_file:
- if parcel.context_record.count():
- # trying to restore a lost parcel
- parcel.operation = parcel.context_record.all()[0].operation
- updated = True
- elif parcel.id:
- parcel.delete()
- return
- else:
- return
- """
-
if updated:
parcel.save()
return