From a36c67369948a95a3470dffb6a9c04d13debd188 Mon Sep 17 00:00:00 2001 From: Ketan <73937490+devketanpro@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:06:44 +0530 Subject: [PATCH] Tooltip not displaying on coverage icon if an event/planning item was created using 'duplicate' option [CPCN-899] (#2079) * add coverage assignee details and coverage status on duplicate planning * added a new config and make changes according config * fix tests --- README.md | 3 +++ server/features/planning_duplicate.feature | 18 +++++++++--------- server/planning/common.py | 4 ++++ server/planning/planning/planning_duplicate.py | 15 ++++++++++++--- server/settings.py | 2 ++ 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8aa912cc7..0c12b9e8e 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,9 @@ Below sections include the config options that can be defined in settings.py. * language (includes `languages` if multilingual is enabled) * definition_short (copies to Planning item's `Description Text`) * priority +* PLANNING_DUPLICATE_RETAIN_ASSIGNEE_DETAILS + * Default: False (the current behavior where assignee details are removed) + * If true, the `assigned_to` field (assignee details) is retained when duplicating planning items with coverages. ### Assignments Config * SLACK_BOT_TOKEN diff --git a/server/features/planning_duplicate.feature b/server/features/planning_duplicate.feature index 66f36e792..0dd0f6a71 100644 --- a/server/features/planning_duplicate.feature +++ b/server/features/planning_duplicate.feature @@ -1,6 +1,6 @@ Feature: Duplicate Planning - @auth @notification + @auth @notification @vocabulary Scenario: Duplicate a Planning item When we post to "planning" with success """ @@ -149,7 +149,7 @@ Feature: Duplicate Planning ] """ - @auth + @auth @vocabulary Scenario: Planning can only be duplicated by user having privileges When we post to "planning" with success """ @@ -184,7 +184,7 @@ Feature: Duplicate Planning Then we get OK response - @auth @notification + @auth @notification @vocabulary Scenario: Coverage workflow_status defaults to draft on duplication item When we post to "planning" with success """ @@ -279,7 +279,7 @@ Feature: Duplicate Planning } """ - @auth @notification + @auth @notification @vocabulary Scenario: Duplicating a posted Planning item won't repost it When we post to "planning" with success """ @@ -333,7 +333,7 @@ Feature: Duplicate Planning ]} """ - @auth + @auth @vocabulary Scenario: Duplicate a past planning item will have current date Given "planning" """ @@ -377,7 +377,7 @@ Feature: Duplicate Planning {"expired": "__no_value__"} """ - @auth + @auth @vocabulary Scenario: Duplicating a Planning item will link to the same Event Given "events" """ @@ -423,7 +423,7 @@ Feature: Duplicate Planning } """ - @auth + @auth @vocabulary Scenario: Duplicating an expired Planning item will remove the link to the Event Given "events" """ @@ -471,7 +471,7 @@ Feature: Duplicate Planning } """ - @auth + @auth @vocabulary Scenario: Duplicating a canceled Planning item will clear the state_reason Given "events" """ @@ -542,7 +542,7 @@ Feature: Duplicate Planning } """ - @auth + @auth @vocabulary Scenario: Duplicating a rescheduled Planning item will clear the state_reason Given "events" """ diff --git a/server/planning/common.py b/server/planning/common.py index d53f8f5ad..717dcbdc0 100644 --- a/server/planning/common.py +++ b/server/planning/common.py @@ -267,6 +267,10 @@ def get_default_coverage_status_qcode_on_ingest(current_app=None): return (current_app or app).config.get("PLANNING_DEFAULT_COVERAGE_STATUS_ON_INGEST", "ncostat:int") +def get_config_planning_duplicate_retain_assignee_details(current_app=None): + return (current_app or app).config.get("PLANNING_DUPLICATE_RETAIN_ASSIGNEE_DETAILS", False) + + def get_coverage_status_from_cv(qcode: str): coverage_states = get_resource_service("vocabularies").find_one(req=None, _id="newscoveragestatus") diff --git a/server/planning/planning/planning_duplicate.py b/server/planning/planning/planning_duplicate.py index 2de22c6ba..1d6c55b63 100644 --- a/server/planning/planning/planning_duplicate.py +++ b/server/planning/planning/planning_duplicate.py @@ -17,7 +17,13 @@ from superdesk.metadata.item import GUID_NEWSML from superdesk.utc import utcnow, utc_to_local from flask import request -from planning.common import ITEM_STATE, WORKFLOW_STATE, TEMP_ID_PREFIX +from planning.common import ( + ITEM_STATE, + WORKFLOW_STATE, + TEMP_ID_PREFIX, + get_coverage_status_from_cv, + get_config_planning_duplicate_retain_assignee_details, +) from copy import deepcopy @@ -99,12 +105,15 @@ def _duplicate_planning(self, original): new_plan["planning_date"] = new_plan["planning_date"] + (local_datetime.date() - planning_datetime.date()) for cov in new_plan.get("coverages") or []: - cov.pop("assigned_to", None) cov.get("planning", {}).pop("workflow_status_reason", None) cov.pop("scheduled_updates", None) cov.get("planning", {})["scheduled"] = new_plan.get("planning_date") cov["coverage_id"] = TEMP_ID_PREFIX + "duplicate" cov["workflow_status"] = WORKFLOW_STATE.DRAFT - cov["news_coverage_status"] = {"qcode": "ncostat:int"} + cov["news_coverage_status"] = get_coverage_status_from_cv("ncostat:int") + cov["news_coverage_status"].pop("is_active", None) + + if not get_config_planning_duplicate_retain_assignee_details(): + cov.pop("assigned_to", None) return new_plan diff --git a/server/settings.py b/server/settings.py index 3518d27a4..4c1064807 100644 --- a/server/settings.py +++ b/server/settings.py @@ -189,3 +189,5 @@ def env(variable, fallback_value=None): ELASTICSEARCH_AUTO_AGGREGATIONS = False PLANNING_DEFAULT_COVERAGE_STATUS_ON_INGEST = "ncostat:int" + +PLANNING_DUPLICATE_RETAIN_ASSIGNEE_DETAILS = False