diff --git a/intervention/models/intervention.py b/intervention/models/intervention.py index 6f721237..766346f5 100644 --- a/intervention/models/intervention.py +++ b/intervention/models/intervention.py @@ -8,6 +8,8 @@ Created on: 15.11.21 import shutil from django.contrib import messages +from django.utils import timezone + from user.models import User from django.db import models, transaction from django.db.models import QuerySet @@ -282,6 +284,22 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec request = self.set_geometry_conflict_message(request) return request + def is_ready_for_publish(self) -> bool: + """ Checks whether the data passes all constraints for being publishable + + Returns: + is_ready (bool) : True|False + """ + now_date = timezone.now().date() + binding_date = self.legal.binding_date + is_binding_date_ready = binding_date is not None and binding_date <= now_date + is_recorded = self.recorded is not None + is_free_of_revocations = not self.legal.revocations.exists() + is_ready = is_binding_date_ready \ + and is_recorded \ + and is_free_of_revocations + return is_ready + class InterventionDocument(AbstractDocument): """ diff --git a/intervention/views.py b/intervention/views.py index ad046155..50856dfb 100644 --- a/intervention/views.py +++ b/intervention/views.py @@ -545,7 +545,7 @@ def report_view(request:HttpRequest, id: str): tab_title = _("Report {}").format(intervention.identifier) # If intervention is not recorded (yet or currently) we need to render another template without any data - if not intervention.recorded: + if not intervention.is_ready_for_publish(): template = "report/unavailable.html" context = { TAB_TITLE_IDENTIFIER: tab_title, diff --git a/konova/models/object.py b/konova/models/object.py index 900542d8..0a83a487 100644 --- a/konova/models/object.py +++ b/konova/models/object.py @@ -283,6 +283,15 @@ class RecordableObjectMixin(models.Model): CHECKED_RECORDED_RESET ) + @abstractmethod + def is_ready_for_publish(self) -> bool: + """ Check for all needed publishing-constraints on the data + + Returns: + is_ready (bool): True|False + """ + raise NotImplementedError("Implement this in the subclass!") + class CheckableObjectMixin(models.Model): # Checks - Refers to "Genehmigen" but optional diff --git a/locale/de/LC_MESSAGES/django.mo b/locale/de/LC_MESSAGES/django.mo index 619b6ef4..a45c4548 100644 Binary files a/locale/de/LC_MESSAGES/django.mo and b/locale/de/LC_MESSAGES/django.mo differ diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index 46827b72..2d3d4093 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -2214,8 +2214,8 @@ msgid "" " " msgstr "" "\n" -" Die Daten, die Sie einsehen möchten, sind in Bearbeitung und " -"daher aktuell nicht öffentlich einsehbar. Schauen Sie zu einem späteren " +" Diese Daten sind noch nicht veröffentlicht und " +"können daher aktuell nicht eingesehen werden. Schauen Sie zu einem späteren " "Zeitpunkt wieder vorbei. \n" " "