Skip to content

Commit

Permalink
add link to cp image to picture coverages
Browse files Browse the repository at this point in the history
CPCN-182
  • Loading branch information
petrjasek committed Jun 14, 2024
1 parent 0adbce5 commit 41ea6eb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/cp/images.py
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
1 change: 1 addition & 0 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
INSTALLED_APPS = [
"cp.sidenav",
"cp.signals",
"cp.images",
"newsroom.auth.saml",
]

Expand Down
32 changes: 32 additions & 0 deletions server/tests/test_images.py
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

0 comments on commit 41ea6eb

Please sign in to comment.