#50 Overlaying geometries

* refactors geometry field into GeoReferencedMixin, holding more handy methods and used in all models, formerly holding the geometry field
* refactors backend admin configuration, so modified, deleted and created are not editable in the backend which also skips loading of all possible choices
* fixes typo in sanitize_db command
* introduces GeometryConflict model, holding a link between two geometries, where one overlaps the other
* adds first (WIP) messages into detail views of ema and intervention for test purposes
This commit is contained in:
2021-12-15 13:59:52 +01:00
parent 262f85e0e0
commit f4541abf20
12 changed files with 179 additions and 23 deletions

View File

@@ -7,15 +7,17 @@ Created on: 15.11.21
"""
import shutil
from django.contrib.auth.models import User
from django.contrib import messages
from django.db import models
from django.db.models import QuerySet
from django.http import HttpRequest
from compensation.models import AbstractCompensation
from ema.managers import EmaManager
from ema.utils.quality import EmaQualityChecker
from konova.models import AbstractDocument, generate_document_file_upload_path, RecordableObjectMixin, ShareableObjectMixin
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE
from konova.utils.message_templates import DATA_UNSHARED_EXPLANATION
class Ema(AbstractCompensation, ShareableObjectMixin, RecordableObjectMixin):
@@ -91,6 +93,13 @@ class Ema(AbstractCompensation, ShareableObjectMixin, RecordableObjectMixin):
)
return docs
def set_status_messages(self, request: HttpRequest):
if not self.is_shared_with(request.user):
messages.info(request, DATA_UNSHARED_EXPLANATION)
self._set_overlapped_by_message(request)
self._set_overlapping_message(request)
return request
class EmaDocument(AbstractDocument):
"""

View File

@@ -138,8 +138,7 @@ def detail_view(request: HttpRequest, id: str):
sum_after_states = after_states.aggregate(Sum("surface"))["surface__sum"] or 0
diff_states = abs(sum_before_states - sum_after_states)
if not is_data_shared:
messages.info(request, DATA_UNSHARED_EXPLANATION)
ema.set_status_messages(request)
context = {
"obj": ema,