From 4e57ca4954d36253b77f8b51d92f5ab6302dd945 Mon Sep 17 00:00:00 2001 From: mpeltriaux Date: Fri, 21 Jan 2022 09:26:41 +0100 Subject: [PATCH] # 83 Publication rework * adds fake-inherited is_ready_for_publish() method to compensation model (not derived from RecordableObjectMixin) to equalize usage of is_ready_for_publish() usage for all data types (compensation can be checked the same way as intervention, ecoaccount or ema) --- compensation/models/compensation.py | 10 ++++++++++ compensation/views/compensation.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compensation/models/compensation.py b/compensation/models/compensation.py index b68ad105..6ebed855 100644 --- a/compensation/models/compensation.py +++ b/compensation/models/compensation.py @@ -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): """ diff --git a/compensation/views/compensation.py b/compensation/views/compensation.py index b555ccf8..323921e4 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.is_ready_for_publish(): + if not comp.is_ready_for_publish(): template = "report/unavailable.html" context = { TAB_TITLE_IDENTIFIER: tab_title,