# 83 Publication rework interventions

* adds abstract is_ready_for_publish method to PublishableObjectMixin which needs to be implemented in subclasses
* adds implementation for intervention model
* adds publishable check to rendering report view
* adds/updates translations
This commit is contained in:
mpeltriaux 2022-01-21 09:02:56 +01:00
parent 1670bf37ab
commit b72426e20f
5 changed files with 30 additions and 3 deletions

View File

@ -8,6 +8,8 @@ Created on: 15.11.21
import shutil import shutil
from django.contrib import messages from django.contrib import messages
from django.utils import timezone
from user.models import User from user.models import User
from django.db import models, transaction from django.db import models, transaction
from django.db.models import QuerySet from django.db.models import QuerySet
@ -282,6 +284,22 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
request = self.set_geometry_conflict_message(request) request = self.set_geometry_conflict_message(request)
return 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): class InterventionDocument(AbstractDocument):
""" """

View File

@ -545,7 +545,7 @@ def report_view(request:HttpRequest, id: str):
tab_title = _("Report {}").format(intervention.identifier) tab_title = _("Report {}").format(intervention.identifier)
# If intervention is not recorded (yet or currently) we need to render another template without any data # 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" template = "report/unavailable.html"
context = { context = {
TAB_TITLE_IDENTIFIER: tab_title, TAB_TITLE_IDENTIFIER: tab_title,

View File

@ -283,6 +283,15 @@ class RecordableObjectMixin(models.Model):
CHECKED_RECORDED_RESET 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): class CheckableObjectMixin(models.Model):
# Checks - Refers to "Genehmigen" but optional # Checks - Refers to "Genehmigen" but optional

Binary file not shown.

View File

@ -2214,8 +2214,8 @@ msgid ""
" " " "
msgstr "" msgstr ""
"\n" "\n"
" Die Daten, die Sie einsehen möchten, sind in Bearbeitung und " " Diese Daten sind noch nicht veröffentlicht und "
"daher aktuell nicht öffentlich einsehbar. Schauen Sie zu einem späteren " "können daher aktuell nicht eingesehen werden. Schauen Sie zu einem späteren "
"Zeitpunkt wieder vorbei. \n" "Zeitpunkt wieder vorbei. \n"
" " " "