generated from superdesk/newsroom-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add link to cp image to picture coverages
CPCN-182
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from urllib.parse import quote | ||
|
||
|
||
def set_photo_coverage_href(coverage, planning_item, deliveries=[]) -> str: | ||
slugline = coverage.get("slugline") | ||
if not slugline: | ||
return "" | ||
return f"https://www.cpimages.com/CS.aspx?VP3=DirectSearch&FT={quote(slugline)}" | ||
|
||
|
||
def init_app(app): | ||
app.set_photo_coverage_href = set_photo_coverage_href |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,7 @@ | |
INSTALLED_APPS = [ | ||
"cp.sidenav", | ||
"cp.signals", | ||
"cp.images", | ||
"newsroom.auth.saml", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from cp.images import set_photo_coverage_href | ||
|
||
|
||
def test_set_photo_coverage_href(): | ||
coverage = { | ||
"coverage_id": "b808c78c-6859-41df-aabd-bd54b3fb4db9", | ||
"workflow_status": "completed", | ||
"coverage_status": "coverage intended", | ||
"watches": [], | ||
"assigned_user_name": "john doe", | ||
"scheduled": "2024-06-16T14:00:00+0000", | ||
"delivery_id": None, | ||
"coverage_provider": "Stringer", | ||
"planning_id": "f71ed214-9fa7-4de4-834b-9da85276015f", | ||
"deliveries": [ | ||
{ | ||
"publish_time": "2024-06-14T12:49:38+0000", | ||
"delivery_state": "published", | ||
"delivery_href": "example.com", | ||
"sequence_no": 0, | ||
} | ||
], | ||
"slugline": "picture slug", | ||
"assigned_desk_name": "Test", | ||
"assigned_desk_email": "[email protected]", | ||
"assigned_user_email": "petr@localhost", | ||
"publish_time": "2024-06-14T12:49:38+0000", | ||
"genre": [], | ||
"coverage_type": "picture", | ||
} | ||
href = set_photo_coverage_href(coverage, {}, []) | ||
assert "https://www.cpimages.com/CS.aspx?VP3=DirectSearch&FT=picture%20slug" == href |