Compare commits

...

4 Commits

Author SHA1 Message Date
mpeltriaux 08884cb370 Merge pull request '# HOTFIX' (#550) from hotfix_indexErrorOnAPIGet into master
Reviewed-on: #550
2026-06-20 12:10:51 +02:00
mpeltriaux 9b5defec6d # HOTFIX
* fixes bug where unfetchable data entries of a GeometryConflict would result in an error via API
2026-06-20 12:10:13 +02:00
mpeltriaux 0425430e65 Merge pull request '# HOTFIX' (#547) from hotfix_indexErrorOnAPIGet into master
Reviewed-on: #547
2026-06-20 09:27:55 +02:00
mpeltriaux fec313445d # HOTFIX
* fixes a bug where detected GeometryConflicts with deleted entries would case an IndexError
2026-06-20 09:27:02 +02:00
3 changed files with 21 additions and 4 deletions
+5 -1
View File
@@ -217,7 +217,11 @@ class AbstractModelAPISerializer:
conflict_geometries = geometry.get_conflict_geometries() conflict_geometries = geometry.get_conflict_geometries()
for geom in conflict_geometries: for geom in conflict_geometries:
try: try:
data = geom.get_data_objects(["identifier", "id"])[0] data = geom.get_data_objects(["identifier", "id"])
if len(data) == 0:
# expected behaviour in case of deleted data object
continue
data = data[0]
except KeyError: except KeyError:
raise AssertionError(f"Geometry {geom.id} is not attached to any entries. Contact an admin!") raise AssertionError(f"Geometry {geom.id} is not attached to any entries. Contact an admin!")
ids.append( ids.append(
+12 -1
View File
@@ -142,11 +142,22 @@ class Geometry(BaseResource):
def get_data_object(self, limit_to_attrs: list = None): def get_data_object(self, limit_to_attrs: list = None):
""" """
Getter for the specific data object which is related to this geometry Getter for the specific data object which is related to this geometry.
!!! Only returns undeleted entries !!!
Returns:
result (str|None): Returns the desired attributes or None if the data object is marked as deleted
""" """
objs = self.get_data_objects(limit_to_attrs) objs = self.get_data_objects(limit_to_attrs)
assert (len(objs) <= 1) assert (len(objs) <= 1)
try:
result = objs.pop() result = objs.pop()
except IndexError:
# If this happens, we just processed a GeometryConflict with an entry which is marked as deleted.
# Therefore we return None
result = None
return result return result
def update_parcels(self): def update_parcels(self):
+3 -1
View File
@@ -679,7 +679,9 @@ class GeoReferencedMixin(models.Model):
conflicting_geometries = self.geometry.get_conflict_geometries() conflicting_geometries = self.geometry.get_conflict_geometries()
data_object_identifiers = [] data_object_identifiers = []
for conflicting_geom in conflicting_geometries: for conflicting_geom in conflicting_geometries:
data_object_identifiers.append(conflicting_geom.get_data_object(["identifier"])) data_obj_id = conflicting_geom.get_data_object(["identifier"])
if data_obj_id:
data_object_identifiers.append(data_obj_id)
add_message = len(data_object_identifiers) > 0 add_message = len(data_object_identifiers) > 0
if add_message: if add_message: