Skip to content

Commit

Permalink
Tooltip not displaying on coverage icon if an event/planning item was…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
devketanpro authored Sep 10, 2024
1 parent ffd3ce2 commit a36c673
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions server/features/planning_duplicate.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: Duplicate Planning

@auth @notification
@auth @notification @vocabulary
Scenario: Duplicate a Planning item
When we post to "planning" with success
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -333,7 +333,7 @@ Feature: Duplicate Planning
]}
"""

@auth
@auth @vocabulary
Scenario: Duplicate a past planning item will have current date
Given "planning"
"""
Expand Down Expand Up @@ -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"
"""
Expand Down Expand Up @@ -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"
"""
Expand Down Expand Up @@ -471,7 +471,7 @@ Feature: Duplicate Planning
}
"""

@auth
@auth @vocabulary
Scenario: Duplicating a canceled Planning item will clear the state_reason
Given "events"
"""
Expand Down Expand Up @@ -542,7 +542,7 @@ Feature: Duplicate Planning
}
"""

@auth
@auth @vocabulary
Scenario: Duplicating a rescheduled Planning item will clear the state_reason
Given "events"
"""
Expand Down
4 changes: 4 additions & 0 deletions server/planning/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
15 changes: 12 additions & 3 deletions server/planning/planning/planning_duplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a36c673

Please sign in to comment.