summaryrefslogtreecommitdiff
path: root/archaeological_operations/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r--archaeological_operations/models.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 6cbac457e..0888345d7 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -31,7 +31,7 @@ from django.contrib.gis.db.models.aggregates import Union
from django.contrib.gis.db.models.functions import Centroid
from django.contrib.postgres.indexes import GinIndex
from django.contrib.sites.models import Site
-from django.db import IntegrityError, transaction
+from django.db import transaction, OperationalError, IntegrityError
from django.db.models import Q, Count, Sum, Max, Avg
from django.db.models.signals import post_save, m2m_changed, post_delete
from django.forms import ValidationError
@@ -194,7 +194,7 @@ class GeographicTownItem(GeoItem):
if self.main_geodata == geo:
self.main_geodata = None
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if q_towns_nb < 2:
# no area - clean
@@ -205,7 +205,7 @@ class GeographicTownItem(GeoItem):
if self.main_geodata == geo:
self.main_geodata = None
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
current_town_geo = None
@@ -218,7 +218,7 @@ class GeographicTownItem(GeoItem):
if self.main_geodata == geo:
self.main_geodata = None
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if not q_geodata_town.filter(source_id=current_town_geo.pk).count():
self.geodata.add(current_town_geo.main_geodata)
@@ -237,13 +237,13 @@ class GeographicTownItem(GeoItem):
self.geodata.remove(geo)
if self.main_geodata == geo:
self.main_geodata = None
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
try:
with transaction.atomic():
self.geodata.add(current_geo_area)
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if current_town_geo:
@@ -257,7 +257,7 @@ class GeographicTownItem(GeoItem):
if self.main_geodata == geo:
self.main_geodata = None
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if current_geo_area:
q_extra_geo_area = q_geodata_area.exclude(pk=current_geo_area.pk)
@@ -270,7 +270,7 @@ class GeographicTownItem(GeoItem):
if self.main_geodata == geo:
self.main_geodata = None
changed = True
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if changed and save:
@@ -3236,7 +3236,7 @@ def parcel_post_save(sender, **kwargs):
# multiple save can cause multiple add
with transaction.atomic():
parcel.operation.towns.add(parcel.town)
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if (
parcel.associated_file
@@ -3247,7 +3247,7 @@ def parcel_post_save(sender, **kwargs):
# multiple save can cause multiple add
with transaction.atomic():
parcel.associated_file.towns.add(parcel.town)
- except IntegrityError:
+ except (OperationalError, IntegrityError):
pass
if parcel.operation and parcel.associated_file:
# parcels are copied between files and operations