From 499555a20aed92b1dc33c374df305e4a6454ce00 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Tue, 17 Oct 2023 16:35:32 +1100 Subject: [PATCH] fix(api): Issues with associations and publish_sign_off fields --- server/tga/sign_off/template_globals.py | 2 +- server/tga/sign_off/utils.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/tga/sign_off/template_globals.py b/server/tga/sign_off/template_globals.py index 73943d0..a7e73dc 100644 --- a/server/tga/sign_off/template_globals.py +++ b/server/tga/sign_off/template_globals.py @@ -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"""
diff --git a/server/tga/sign_off/utils.py b/server/tga/sign_off/utils.py index 923be2f..7ee3afb 100644 --- a/server/tga/sign_off/utils.py +++ b/server/tga/sign_off/utils.py @@ -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"]) @@ -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 :]