summaryrefslogtreecommitdiff
path: root/archaeological_context_records/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r--archaeological_context_records/models.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 21640920e..f464275bf 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -422,12 +422,10 @@ class GeographicSubTownItem(GeoItem):
has_geo_town = (
town and town.main_geodata and town.main_geodata.multi_polygon
)
- if has_geo_town:
- bad_towns = q_geodata_current_town
- elif town:
+
+ bad_towns = q_geodata_current_town
+ if town:
bad_towns = q_geodata_current_town.exclude(source_id=town.id)
- else:
- return
modified = False
for bad_town in bad_towns.all():
@@ -446,15 +444,18 @@ class GeographicSubTownItem(GeoItem):
if not self.main_geodata:
self.main_geodata = upper.main_geodata
+ if modified and save:
+ if settings.USE_BACKGROUND_TASK and hasattr(self, "no_post_process"):
+ self.no_post_process()
+ else:
+ self.skip_history_when_saving = True
+ self._no_move = True
+ self._post_saved_geo = False
+ self._no_down_model_update = False
+ self.save()
+
if not has_geo_town:
- if modified:
- if save:
- self.skip_history_when_saving = True
- self._no_move = True
- self.save()
- else:
- return True
- return
+ return modified
if not q_geodata_current_town.filter(source_id=town.id).count():
try:
@@ -463,12 +464,12 @@ class GeographicSubTownItem(GeoItem):
self.geodata.add(town.main_geodata)
except (OperationalError, IntegrityError):
pass
+ if not modified:
+ return False
if save:
post_save_geo(self.__class__, instance=self, created=False,
update_fields=False, raw=False, using="default")
- else:
- return True
- return False
+ return True
class ContextRecord(