Reviewed-on: #501
This commit is contained in:
commit
22cddb9902
@ -10,6 +10,7 @@ import json
|
||||
from django.contrib.gis.db.models import MultiPolygonField
|
||||
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
||||
from django.db import models, transaction
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
from django.contrib.gis.geos import MultiPolygon
|
||||
|
||||
@ -109,17 +110,26 @@ class Geometry(BaseResource):
|
||||
objs (list): The list of objects
|
||||
"""
|
||||
objs = []
|
||||
sets = [
|
||||
|
||||
# Some related data sets can be processed rather easily
|
||||
regular_sets = [
|
||||
self.intervention_set,
|
||||
self.compensation_set,
|
||||
self.ema_set,
|
||||
self.ecoaccount_set,
|
||||
]
|
||||
for _set in sets:
|
||||
for _set in regular_sets:
|
||||
set_objs = _set.filter(
|
||||
deleted=None
|
||||
)
|
||||
objs += set_objs
|
||||
|
||||
# ... but we need a special treatment for compensations, since they can be deleted directly OR inherit their
|
||||
# de-facto-deleted status from their deleted parent intervention
|
||||
comp_objs = self.compensation_set.filter(
|
||||
Q(deleted=None) & Q(intervention__deleted=None)
|
||||
)
|
||||
objs += comp_objs
|
||||
|
||||
return objs
|
||||
|
||||
def get_data_object(self):
|
||||
|
||||
@ -677,12 +677,12 @@ class GeoReferencedMixin(models.Model):
|
||||
return request
|
||||
|
||||
instance_objs = []
|
||||
conflicts = self.geometry.conflicts_geometries.all()
|
||||
conflicts = self.geometry.conflicts_geometries.iterator()
|
||||
|
||||
for conflict in conflicts:
|
||||
instance_objs += conflict.affected_geometry.get_data_objects()
|
||||
|
||||
conflicts = self.geometry.conflicted_by_geometries.all()
|
||||
conflicts = self.geometry.conflicted_by_geometries.iterator()
|
||||
for conflict in conflicts:
|
||||
instance_objs += conflict.conflicting_geometry.get_data_objects()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user