From 469dabf6aaab5fee48476e12bea896fab3003338 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Fri, 21 Jan 2022 09:22:43 +0100 Subject: [PATCH] # 83 Publication rework EcoAccount Compensation * adds implementation for is_ready_for_publish() on compensation (uses intervention's implementation) and EcoAccount --- compensation/models/eco_account.py | 10 ++++++++++ compensation/views/compensation.py | 2 +- compensation/views/eco_account.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compensation/models/eco_account.py b/compensation/models/eco_account.py index 7d339b4d..84a61409 100644 --- a/compensation/models/eco_account.py +++ b/compensation/models/eco_account.py @@ -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): """ diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py index ab11a62a..b555ccf8 100644 --- a/compensation/views/compensation.py +++ b/compensation/views/compensation.py @@ -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.intervention.is_ready_for_publish(): template = "report/unavailable.html" context = { TAB_TITLE_IDENTIFIER: tab_title, diff --git a/compensation/views/eco_account.py b/compensation/views/eco_account.py index 14caf9d3..5c061b96 100644 --- a/compensation/views/eco_account.py +++ b/compensation/views/eco_account.py @@ -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,