# 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:
		
							parent
							
								
									1670bf37ab
								
							
						
					
					
						commit
						b72426e20f
					
				@ -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):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -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,
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@ -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"
 | 
			
		||||
"            "
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user