Skip to content

Commit

Permalink
fix(api): Issues with associations and publish_sign_off fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Oct 17, 2023
1 parent 05d4eb6 commit 499555a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/tga/sign_off/template_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def render_tag_list(label: str, values: List[str]):
def render_featuremedia_image(item):
featuremedia = item["associations"]["featuremedia"]
image_url = featuremedia["renditions"]["viewImage"]["href"]
alt_text = featuremedia["alt_text"]
alt_text = featuremedia.get("alt_text") or featuremedia.get("description_text") or featuremedia.get("caption")

return f"""
<div class="sd-input sd-input--x-large sd-input--boxed-style sd-input--boxed-label">
Expand Down
4 changes: 3 additions & 1 deletion server/tga/sign_off/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _get_publish_sign_off_data(item: Dict[str, Any]) -> Optional[PublishSignOffD
sign_off["user_id"] = ObjectId(sign_off["user_id"])

return publish_sign_off
else:
elif item["extra"]["publish_sign_off"].get("user_id"):
# This is the legacy format (AuthorSignOffData), change it to PublishSignOffData
author_sign_off: AuthorSignOffData = item["extra"]["publish_sign_off"]
author_sign_off["user_id"] = ObjectId(author_sign_off["user_id"])
Expand Down Expand Up @@ -127,6 +127,8 @@ def modify_asset_urls(item, author_id: ObjectId):
item["body_html"] = new_body_html

for key, association in (item.get("associations") or {}).items():
if association is None:
continue
for size_name, rendition in (association.get("renditions") or {}).items():
rendition_href = rendition["href"]
asset_filename = rendition_href[rendition_href.index(url_prefix) + url_prefix_len :]
Expand Down

0 comments on commit 499555a

Please sign in to comment.