Merge pull request '83_Publication_rework' (#84) from 83_Publication_rework into master
Reviewed-on: SGD-Nord/konova#84
This commit is contained in:
		
						commit
						b9d532aa81
					
				@ -290,6 +290,16 @@ class Compensation(AbstractCompensation, CEFMixin, CoherenceMixin):
 | 
			
		||||
        """
 | 
			
		||||
        self.intervention.mark_as_edited(user, request, edit_comment)
 | 
			
		||||
 | 
			
		||||
    def is_ready_for_publish(self) -> bool:
 | 
			
		||||
        """ Not inherited by RecordableObjectMixin
 | 
			
		||||
 | 
			
		||||
        Simplifies same usage for compensations as for other datatypes
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            is_ready (bool): True|False
 | 
			
		||||
        """
 | 
			
		||||
        return self.intervention.is_ready_for_publish()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CompensationDocument(AbstractDocument):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -193,6 +193,16 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
 | 
			
		||||
            )
 | 
			
		||||
        return deduction
 | 
			
		||||
 | 
			
		||||
    def is_ready_for_publish(self) -> bool:
 | 
			
		||||
        """ Checks whether the data passes all constraints for being publishable
 | 
			
		||||
 | 
			
		||||
        Returns:
 | 
			
		||||
            is_ready (bool) : True|False
 | 
			
		||||
        """
 | 
			
		||||
        is_recorded = self.recorded is not None
 | 
			
		||||
        is_ready = is_recorded
 | 
			
		||||
        return is_ready
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EcoAccountDocument(AbstractDocument):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -451,7 +451,7 @@ def report_view(request: HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
    tab_title = _("Report {}").format(comp.identifier)
 | 
			
		||||
    # If intervention is not recorded (yet or currently) we need to render another template without any data
 | 
			
		||||
    if not comp.intervention.recorded:
 | 
			
		||||
    if not comp.is_ready_for_publish():
 | 
			
		||||
        template = "report/unavailable.html"
 | 
			
		||||
        context = {
 | 
			
		||||
            TAB_TITLE_IDENTIFIER: tab_title,
 | 
			
		||||
 | 
			
		||||
@ -553,7 +553,7 @@ def report_view(request:HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
    tab_title = _("Report {}").format(acc.identifier)
 | 
			
		||||
    # If intervention is not recorded (yet or currently) we need to render another template without any data
 | 
			
		||||
    if not acc.recorded:
 | 
			
		||||
    if not acc.is_ready_for_publish():
 | 
			
		||||
        template = "report/unavailable.html"
 | 
			
		||||
        context = {
 | 
			
		||||
            TAB_TITLE_IDENTIFIER: tab_title,
 | 
			
		||||
 | 
			
		||||
@ -109,6 +109,16 @@ class Ema(AbstractCompensation, ShareableObjectMixin, RecordableObjectMixin):
 | 
			
		||||
        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
 | 
			
		||||
        """
 | 
			
		||||
        is_recorded = self.recorded is not None
 | 
			
		||||
        is_ready = is_recorded
 | 
			
		||||
        return is_ready
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class EmaDocument(AbstractDocument):
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
@ -464,7 +464,7 @@ def report_view(request:HttpRequest, id: str):
 | 
			
		||||
 | 
			
		||||
    tab_title = _("Report {}").format(ema.identifier)
 | 
			
		||||
    # If intervention is not recorded (yet or currently) we need to render another template without any data
 | 
			
		||||
    if not ema.recorded:
 | 
			
		||||
    if not ema.is_ready_for_publish():
 | 
			
		||||
        template = "report/unavailable.html"
 | 
			
		||||
        context = {
 | 
			
		||||
            TAB_TITLE_IDENTIFIER: tab_title,
 | 
			
		||||
 | 
			
		||||
@ -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