diff --git a/server/features/assignments_planning_publish.feature b/server/features/assignments_planning_publish.feature index 7505bdfce..4bcd9e2c4 100644 --- a/server/features/assignments_planning_publish.feature +++ b/server/features/assignments_planning_publish.feature @@ -735,6 +735,7 @@ Feature: For posted planning item changes in assignment state post a planning it "type": "text", "headline": "test headline", "slugline": "test slugline", + "state": "in_progress", "task": { "desk": "#desks._id#", "stage": "#desks.incoming_stage#" @@ -802,6 +803,40 @@ Feature: For posted planning item changes in assignment state post a planning it ] } """ + When we publish "123" with "publish" type and "published" state + Then we get OK response + When we transmit items + When we get "published_planning?sort=item_id,version" + Then we get list with 4 items + Then we store "PLANNING" with 4 item + When we get "published_planning?where={\"item_id\": \"#PLANNING.item_id#\", \"version\": #PLANNING.version#}" + Then we get list with 1 items + Then we get transmitted item "/tmp/#PLANNING.item_id#-#PLANNING.version#-4.txt" + """ + { + "state": "scheduled", + "pubstatus": "usable", + "guid": "#PLANNING.item_id#", + "agendas": [{"name": "TestAgenda", "is_enabled": true}], + "coverages": [ + { + "coverage_id": "#firstcoverage#", + "workflow_status": "completed", + "planning": { + "ednote": "test coverage, I want 250 words", + "headline": "test headline", + "slugline": "test slugline", + "g2_content_type" : "text" + }, + "news_coverage_status": { + "qcode": "ncostat:int" + }, + "deliveries": [{"item": "123"}], + "coverage_provider": null + } + ] + } + """ When we post to "assignments/unlink" with success """ [{ @@ -829,11 +864,11 @@ Feature: For posted planning item changes in assignment state post a planning it """ When we transmit items When we get "published_planning?sort=item_id,version" - Then we get list with 4 items - Then we store "PLANNING" with 4 item + Then we get list with 5 items + Then we store "PLANNING" with 5 item When we get "published_planning?where={\"item_id\": \"#PLANNING.item_id#\", \"version\": #PLANNING.version#}" Then we get list with 1 items - Then we get transmitted item "/tmp/#PLANNING.item_id#-#PLANNING.version#-4.txt" + Then we get transmitted item "/tmp/#PLANNING.item_id#-#PLANNING.version#-5.txt" """ { "state": "scheduled", @@ -859,6 +894,64 @@ Feature: For posted planning item changes in assignment state post a planning it ] } """ + When we post to "assignments/link" + """ + [{ + "assignment_id": "#firstassignment#", + "item_id": "#archive._id#", + "reassign": false + }] + """ + Then we get OK response + When we get "archive/#archive._id#" + Then we get existing resource + """ + {"assignment_id": "#firstassignment#"} + """ + When we get "/assignments/#firstassignment#" + Then we get existing resource + """ + { + "_id": "#firstassignment#", + "assigned_to": { + "desk": "#desks._id#", + "state": "completed" + }, + "coverage_item": "#firstcoverage#" + } + """ + When we transmit items + When we get "published_planning?sort=item_id,version" + Then we get list with 6 items + Then we store "PLANNING" with 6 item + When we get "published_planning?where={\"item_id\": \"#PLANNING.item_id#\", \"version\": #PLANNING.version#}" + Then we get list with 1 items + Then we get transmitted item "/tmp/#PLANNING.item_id#-#PLANNING.version#-6.txt" + """ + { + "state": "scheduled", + "pubstatus": "usable", + "guid": "#PLANNING.item_id#", + "agendas": [{"name": "TestAgenda", "is_enabled": true}], + "coverages": [ + { + "coverage_id": "#firstcoverage#", + "workflow_status": "completed", + "planning": { + "ednote": "test coverage, I want 250 words", + "headline": "test headline", + "slugline": "test slugline", + "g2_content_type" : "text" + }, + "news_coverage_status": { + "qcode": "ncostat:int" + }, + "deliveries": [{"item": "123"}], + "coverage_provider": null + } + ] + } + """ @auth @vocabularies Scenario: Publish Planning item on confirm and revert availability diff --git a/server/planning/assignments/assignments_link.py b/server/planning/assignments/assignments_link.py index 02b01d953..6afa2d580 100644 --- a/server/planning/assignments/assignments_link.py +++ b/server/planning/assignments/assignments_link.py @@ -46,11 +46,6 @@ def create(self, docs): if user and str(user.get(config.ID_FIELD)) != (assignment.get('assigned_to') or {}).get('user'): updates['assigned_to']['user'] = str(user.get(config.ID_FIELD)) - if item.get(ITEM_STATE) in [CONTENT_STATE.PUBLISHED, CONTENT_STATE.CORRECTED]: - assignments_complete.update(assignment[config.ID_FIELD], updates, assignment) - else: - assignments_service.patch(assignment[config.ID_FIELD], updates) - # reference the item to the assignment production.system_update( item[config.ID_FIELD], @@ -58,18 +53,24 @@ def create(self, docs): item ) - # if the item is publish then update those items as well - if item.get(ITEM_STATE) in PUBLISH_STATES: - get_resource_service('published').update_published_items( - item[config.ID_FIELD], - 'assignment_id', assignment[config.ID_FIELD]) - get_resource_service('delivery').post([{ 'item_id': item[config.ID_FIELD], 'assignment_id': assignment[config.ID_FIELD], 'planning_id': assignment['planning_item'], 'coverage_id': assignment['coverage_item'] }]) + + if item.get(ITEM_STATE) in [CONTENT_STATE.PUBLISHED, CONTENT_STATE.CORRECTED]: + assignments_complete.update(assignment[config.ID_FIELD], updates, assignment) + else: + assignments_service.patch(assignment[config.ID_FIELD], updates) + + # if the item is publish then update those items as well + if item.get(ITEM_STATE) in PUBLISH_STATES: + get_resource_service('published').update_published_items( + item[config.ID_FIELD], + 'assignment_id', assignment[config.ID_FIELD]) + item['assignment_id'] = assignment[config.ID_FIELD] # Save assignment history