diff --git a/konova/admin.py b/konova/admin.py index 07d692d7..ff82ac2b 100644 --- a/konova/admin.py +++ b/konova/admin.py @@ -151,7 +151,7 @@ class ResubmissionAdmin(BaseResourceAdmin): # Outcommented for a cleaner admin backend on production -#admin.site.register(Geometry, GeometryAdmin) +admin.site.register(Geometry, GeometryAdmin) #admin.site.register(Parcel, ParcelAdmin) #admin.site.register(District, DistrictAdmin) #admin.site.register(Municipal, MunicipalAdmin) diff --git a/konova/migrations/0016_remove_parcelintersection_calculated_on.py b/konova/migrations/0016_remove_parcelintersection_calculated_on.py new file mode 100644 index 00000000..c4a0f92d --- /dev/null +++ b/konova/migrations/0016_remove_parcelintersection_calculated_on.py @@ -0,0 +1,17 @@ +# Generated by Django 5.0.1 on 2024-02-16 07:34 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('konova', '0015_geometry_parcel_calculation_end_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='parcelintersection', + name='calculated_on', + ), + ] diff --git a/konova/models/geometry.py b/konova/models/geometry.py index 938c8526..254ace44 100644 --- a/konova/models/geometry.py +++ b/konova/models/geometry.py @@ -303,17 +303,6 @@ class Geometry(BaseResource): municipals = Municipal.objects.filter(id__in=municipals).order_by("name") return municipals - def count_underlying_parcels(self): - """ Getter for number of underlying parcels - - Returns: - - """ - num_parcels = self.parcels.filter( - parcelintersection__calculated_on__isnull=False, - ).count() - return num_parcels - def as_feature_collection(self, srid=DEFAULT_SRID_RLP): """ Returns a FeatureCollection structure holding all polygons of the MultiPolygon as single features diff --git a/konova/models/object.py b/konova/models/object.py index e2acaebd..f1a41c97 100644 --- a/konova/models/object.py +++ b/konova/models/object.py @@ -672,17 +672,6 @@ class GeoReferencedMixin(models.Model): result = self.geometry.get_underlying_parcels() return result - def count_underlying_parcels(self): - """ Getter for number of underlying parcels - - Returns: - - """ - result = 0 - if self.geometry is not None: - result = self.geometry.count_underlying_parcels() - return result - def set_geometry_conflict_message(self, request: HttpRequest): if self.geometry is None: return request diff --git a/konova/models/parcel.py b/konova/models/parcel.py index cc91e006..7cf00448 100644 --- a/konova/models/parcel.py +++ b/konova/models/parcel.py @@ -160,19 +160,9 @@ class Parcel(UuidModel): class ParcelIntersection(UuidModel): - """ ParcelIntersection is an intermediary model, which is used to configure the + """ + ParcelIntersection is an intermediary model, which is used to add extras to the M2M relation between Parcel and Geometry. - - Based on uuids, we will not have (practically) any problems on outrunning primary keys - and extending the model with calculated_on timestamp, we can 'hide' entries while they - are being recalculated and keep track on the last time they have been calculated this - way. - - Please note: The calculated_on describes when the relation between the Parcel and the Geometry - has been established. The updated_on field of Parcel describes when this Parcel has been - changed the last time. - """ parcel = models.ForeignKey(Parcel, on_delete=models.CASCADE) geometry = models.ForeignKey("konova.Geometry", on_delete=models.CASCADE) - calculated_on = models.DateTimeField(auto_now_add=True, null=True, blank=True) diff --git a/konova/tasks.py b/konova/tasks.py index f333bb25..ea68cde0 100644 --- a/konova/tasks.py +++ b/konova/tasks.py @@ -11,15 +11,8 @@ def celery_update_parcels(geometry_id: str, recheck: bool = True): try: geom = Geometry.objects.get(id=geometry_id) geom.parcels.clear() - #objs = geom.parcelintersection_set.all() - #for obj in objs: - # obj.calculated_on = None - #ParcelIntersection.objects.bulk_update( - # objs, - # ["calculated_on"] - #) - geom.update_parcels() + except ObjectDoesNotExist: if recheck: sleep(5) diff --git a/konova/utils/schneider/fetcher.py b/konova/utils/schneider/fetcher.py index 9eefb612..87aa7517 100644 --- a/konova/utils/schneider/fetcher.py +++ b/konova/utils/schneider/fetcher.py @@ -31,7 +31,7 @@ class ParcelFetcher: buffer_threshold = 0.001 geom = geometry.geom.buffer(-buffer_threshold) if geom.area < buffer_threshold: - # Fallback for malicious geometries which are way too small but would disappear on buffering + # Fallback for malicious geometries which are way too small and would disappear on negative buffering geom = geometry.geom self.geojson = geom.ewkt self.results = []