Skip to content

Commit c66af69

Browse files
committed
[STT-1622] feat: Add preserve_embargo_and_schedule parameter to duplicate API
Add support for preserving embargo and schedule fields when duplicating via a request parameter. When preserve_embargo_and_schedule is set to true in the duplicate request, the fields embargo, publish_schedule, and schedule_settings will be preserved on the duplicated item. Changes: - Added preserve_embargo_and_schedule field to DuplicateResource schema - Updated DuplicateService.create_async() to check the request parameter - Added test scenario for the new functionality
1 parent b5b5072 commit c66af69

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

apps/duplication/archive_duplication.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class DuplicateResource(Resource):
3939
"stage": Resource.rel("stages", False, required=False),
4040
"type": {"type": "string", "required": True},
4141
"item_id": {"type": "string", "required": False},
42+
"preserve_embargo_and_schedule": {"type": "boolean", "required": False},
4243
}
4344

4445
url = "archive/<{0}:guid>/duplicate".format(item_url)
@@ -100,9 +101,14 @@ async def create_async(self, docs, **kwargs):
100101
if not doc.get("desk"): # item copied to personal space
101102
archived_doc["state"] = CONTENT_STATE.PROGRESS
102103
new_guid = await archive_service.duplicate_content(archived_doc)
103-
else: # item copied to desk - preserve embargo and schedule fields
104-
extra_fields = [EMBARGO, PUBLISH_SCHEDULE, SCHEDULE_SETTINGS]
105-
new_guid = await archive_service.duplicate_content(archived_doc, extra_fields=extra_fields)
104+
else: # item copied to desk
105+
# Check request parameter for preserving embargo and schedule fields
106+
preserve_schedule = doc.get("preserve_embargo_and_schedule", False)
107+
if preserve_schedule:
108+
extra_fields = [EMBARGO, PUBLISH_SCHEDULE, SCHEDULE_SETTINGS]
109+
new_guid = await archive_service.duplicate_content(archived_doc, extra_fields=extra_fields)
110+
else:
111+
new_guid = await archive_service.duplicate_content(archived_doc)
106112

107113
guid_of_duplicated_items.append(new_guid)
108114

features/content_duplication.feature

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,7 @@ Feature: Duplication of Content
356356
{"desk": "#desks._id#","type": "archive"}
357357
"""
358358
And we get "/archive/#duplicate._id#"
359-
Then we get existing resource
360-
"""
361-
{"publish_schedule": "#DATE+1#"}
362-
"""
359+
Then there is no "publish_schedule" in response
363360

364361
@auth
365362
Scenario: Duplicate a published item and original item's ID is present in the duplicated item
@@ -641,3 +638,20 @@ Feature: Duplication of Content
641638
"""
642639
When we get "/archive/#duplicate._id#"
643640
Then we get "auto_publish" does not exist
641+
642+
@auth
643+
Scenario: Duplicate preserves embargo and schedule when preserve flag is set
644+
When we patch "/archive/123"
645+
"""
646+
{"embargo": "#DATE+2#", "publish_schedule": "#DATE+1#"}
647+
"""
648+
Then we get response code 200
649+
When we post to "/archive/123/duplicate" with success
650+
"""
651+
{"desk": "#desks._id#","type": "archive", "preserve_embargo_and_schedule": true}
652+
"""
653+
And we get "/archive/#duplicate._id#"
654+
Then we get existing resource
655+
"""
656+
{"embargo": "#DATE+2#", "publish_schedule": "#DATE+1#"}
657+
"""

0 commit comments

Comments
 (0)