From e99b74c0424b62c63edba7789fbfa29450079308 Mon Sep 17 00:00:00 2001 From: Ketan <73937490+devketanpro@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:07:12 +0530 Subject: [PATCH] add new should_udpate func [SDCP-742] (#1963) * add new should_udpate func [SDCP-742] * update params * refactore logic --- server/planning/events/events.py | 9 +++++++++ server/planning/planning/planning.py | 3 +++ 2 files changed, 12 insertions(+) diff --git a/server/planning/events/events.py b/server/planning/events/events.py index 93089abc7..18aff08f7 100644 --- a/server/planning/events/events.py +++ b/server/planning/events/events.py @@ -797,6 +797,15 @@ def delete_event_files(self, updates, original): if events_using_file.count() == 0: files_service.delete_action(lookup={"_id": file}) + def should_update(self, old_item, new_item, provider): + return old_item is None or not any( + [ + old_item.get("version_creator"), + old_item.get("pubstatus") == "cancelled", + old_item.get("state") == "killed", + ] + ) + class EventsResource(superdesk.Resource): """Resource for events data model diff --git a/server/planning/planning/planning.py b/server/planning/planning/planning.py index 4e130b57c..5ffec82d7 100644 --- a/server/planning/planning/planning.py +++ b/server/planning/planning/planning.py @@ -257,6 +257,9 @@ def on_duplicated(self, doc, parent_id): def on_locked_planning(self, item, user_id): self.generate_related_assignments([item]) + def should_update(self, old_item, new_item, provider): + return True + @staticmethod def set_ingest_provider_sequence(item, provider): """Sets the value of ingest_provider_sequence in item.