summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-06-17 02:41:03 +0200
committerÉtienne Loks <etienne.loks@proxience.com>2015-06-17 02:41:03 +0200
commitc5920cbb296369478defce4da50202a880ef2f80 (patch)
tree42983cf4fc100c70a1e22b3cf20f3b492eab94ed
parent00d6408e1542fd4f2d4a9db468a0b1ca429c20ff (diff)
parentc85ee3fcb5b594fc4634a085e8fa59bbafd79ad1 (diff)
downloadIshtar-c5920cbb296369478defce4da50202a880ef2f80.tar.bz2
Ishtar-c5920cbb296369478defce4da50202a880ef2f80.zip
Merge branch 'stable'
-rw-r--r--archaeological_operations/models.py10
-rw-r--r--archaeological_operations/tests.py4
2 files changed, 12 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 20d7cf79f..6b44fb924 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -722,7 +722,6 @@ class Parcel(LightHistorizedItem):
for nb in grouped[-1].parcel_numbers]
return grouped
-
@classmethod
def render_parcels(cls, parcels):
parcels = cls.grouped_parcels(parcels)
@@ -753,9 +752,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:
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 2ec79279e..c7e75da1b 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -156,6 +156,10 @@ class ImportOperationTest(TestCase):
sorted([p.parcel_number for p in last_parcels]))
self.assertEqual(sections,
sorted([p.section for p in last_parcels]))
+ last_ope = models.Operation.objects.order_by('-pk').all()[0]
+ towns_ope = last_ope.towns.all()
+ for p in last_parcels:
+ self.assertTrue(p.town in towns_ope)
def testParseParcels(self):