From 884aaca0b38a6ffd1a2718e71504f2a8c1b24824 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Fri, 21 Jan 2022 09:02:56 +0100 Subject: [PATCH] # 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 --- intervention/models/intervention.py | 18 ++++++++++++++++++ intervention/views.py | 2 +- konova/models/object.py | 9 +++++++++ locale/de/LC_MESSAGES/django.mo | Bin 34713 -> 34703 bytes locale/de/LC_MESSAGES/django.po | 4 ++-- 5 files changed, 30 insertions(+), 3 deletions(-) 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 619b6ef4f243212e38b6b5aceaefebcb847129ec..a45c4548dff4c50dcfc5d39c7f0cad8b76498fb3 100644 GIT binary patch delta 3834 zcmXxm2~d_r9LMoh5fBAbloUl@hQUNrM2kcmF-Mg07|kP(N)cW_z*mJA%`#ph@XRY_ z8qX=y(VEgJEK(Zp!P{yIZ7}Z+E62&2EX%aMKX#jO{Os=Y?CyX6yZgLsSkrvXn&uyz zi3ogXj47C8%qHwQ*_g4o7i%%(8Dsco4)EW8jGkgl95!H2`~#z~`&47v;Q$Q93=GGy z7>&>3dMrV`*JheA?XlZ56KHxdnT8}9(lG|-Vl1w}PWX;%KkU5d+W$no*LJ!MtS>%9 zeH?bieC&u7*a6qO_Fb<1`1FA7aEXTAyl@8dj&O}X+i;-A{ZE-bf zrEg*w)}k_V7+c^uR7M(I`wi#40EJdOhXiV3(D6;Lg< z!OyTOeuJ9uE{0(6^LG3QRKT53TMpmG0{avd$O+Vh*HJ0GkIF=| znbt5=;8Cbdbw)k!hw7h-+Oi3#t;xnv<~Iu|Or)XQc@A}2du7>yj-t-Q1#FGCP?`7( z6;RkLJ5hqOFKSC4M+NkRYafYChZB|2d~C)1ri_A8whXnW)!4F`G5b&%IGAlCK7&f( zRp)Q0fr4^u{}|ND6HqH2jGAz=d+tL8w#c==iUIA#CJGw39+UBF)QVeqjmg8Vr~oTb zhiVP#I&DEsSc6LGNsPrysKD=`G8UR^`*%Q{k?xp^X}RQI6P41S$d)-@N1cVus1#Qokaz75u4-BsD8Jw1>V8O@h{Z)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|4S(-#Veib@OJ7SVlO;|8lcIwM?GcC5$ZiqnfL>f@E>Q} zr){RXV+Y#vQRA1PCVs`a4*m8tY;z5@s1%(*9l{?_6a0)lu?aOm$5OkJ6x6l43w8R_ zPwOxCyn8YSb;NFD3t)@F)%1tJA1!bsqJ*e;GAl%V+EWol$!|6t$=0 zP=|CDY9ZyQerr%$x&t$?9u-J@nSHMtYTRLEJ zG~`*EnGC#@dM2vh6x75;*d158`VQ`n+vCpw;%t8fH zjXI3`QD@{3Y6Ztphwq$gKaYCG+sJ&l}3TPv0%eJB>sKyAaLj~|9>I{8@=@`LBLf(VPSc+a(3U5(R%J$$$ zJcqjXUDq^qN%Hjxdh7-JDayu3>N&1H9W~W#R0u&-=!@L*QfE2p_wadC|K+InSGxKe zs3omMot90meeVnIf>zTI#e+Kc;2>(iBd7_Fx%Sf-MZE!=k0TDCp75gmh-Y9L^+m3} z6&27K%*J!r35UL9kN4P@a_sTRqu~x7EW_@&*?ADPt5>im{*C&%x&3AP4b4J*`<_I- zSK;a_c4a0H9^rcr=9UCP{k%EBfH#r9fnaEHpdb+PifVV~7c@Uw91P9zf+25IAh$R# z5G)CY=6PY7=HwOxioM(gCE-9}p%)7Bx>vhzdmDlfNqfHyI}AUDjQnxQPL SCxIew@xt1wT~{Y>9Q;4ci7O}o 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" " "