Skip to content

Commit

Permalink
Merge cbd167e into 07f814c
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayur Dhamanwala committed Jan 8, 2019
2 parents 07f814c + cbd167e commit 5ecef94
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 14 deletions.
99 changes: 96 additions & 3 deletions server/features/assignments_planning_publish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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#"
Expand Down Expand Up @@ -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
"""
[{
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down
23 changes: 12 additions & 11 deletions server/planning/assignments/assignments_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,31 @@ 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],
{'assignment_id': assignment[config.ID_FIELD]},
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
Expand Down

0 comments on commit 5ecef94

Please sign in to comment.