summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-06-17 02:40:01 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2015-06-17 02:40:01 +0200
commitc85ee3fcb5b594fc4634a085e8fa59bbafd79ad1 (patch)
tree5329deebb75ad591bf2ea9a5af9ef5fce0f2b91a /archaeological_operations/models.py
parentff26df85f5f325e63378b81f9cc89fe4f7a8f9c6 (diff)
downloadIshtar-c85ee3fcb5b594fc4634a085e8fa59bbafd79ad1.tar.bz2
Ishtar-c85ee3fcb5b594fc4634a085e8fa59bbafd79ad1.zip
Parcel: when associating a new town report it to operation and files
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 51f67d723..a11931c62 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -714,7 +714,6 @@ class Parcel(LightHistorizedItem):
for nb in grouped[-1].parcel_numbers]
return grouped
-
@classmethod
def render_parcels(cls, parcels):
parcels = cls.grouped_parcels(parcels)
@@ -745,9 +744,16 @@ class Parcel(LightHistorizedItem):
return settings.JOINT.join(items)
def parcel_post_save(sender, **kwargs):
- if not kwargs['instance'] or not FILES_AVAILABLE:
+ if not kwargs['instance']:
return
parcel = kwargs['instance']
+ if parcel.operation and parcel.town not in parcel.operation.towns.all():
+ parcel.operation.towns.add(parcel.town)
+ elif FILES_AVAILABLE and parcel.associated_file and \
+ parcel.town not in parcel.associated_file.towns.all():
+ parcel.associated_file.towns.add(parcel.town)
+ if not FILES_AVAILABLE:
+ return
if parcel.operation and parcel.associated_file:
return
if parcel.operation and parcel.operation.associated_file: