in bedrock/contentful/api.py [0:0]
def get_info_data(self, entry_obj, seo_obj=None):
entry_fields = entry_obj.fields()
if seo_obj:
seo_fields = seo_obj.fields()
else:
seo_fields = None
page_type = entry_obj.content_type.id
data = {}
data.update(self._get_info_data__slug_title_blurb(entry_fields, seo_fields))
data.update(self._get_info_data__theme_campaign(entry_fields, data["slug"]))
data.update(self._get_info_data__locale(page_type, entry_fields, entry_obj))
campaign = data.pop("campaign")
data.update(
{
# eg www.mozilla.org-firefox-accounts or www.mozilla.org-firefox-sync
"utm_source": f"www.mozilla.org-{campaign}",
"utm_campaign": campaign, # eg firefox-sync
}
)
_preview_image = self._get_preview_image_from_fields(entry_fields)
if _preview_image:
data["image"] = _preview_image
if seo_fields:
_preview_image = self._get_preview_image_from_fields(seo_fields)
_seo_fields = deepcopy(seo_fields) # NB: don't mutate the source dict
if _preview_image:
_seo_fields["image"] = _preview_image
else:
if data.get("locale") != DEFAULT_LOCALE:
# Fall back to stealing the SEO image from the default locale, if we can
_seo_fields["image"] = self._get_image_from_default_locale_seo_object(
contentful_id=entry_obj.sys["id"],
)
# We don't need the preview_image key if we've had it in the past, and
# if reading it fails then we don't want it sticking around, either
_seo_fields.pop("preview_image", None)
data.update({"seo": _seo_fields})
data.update(
self._get_info_data__category_tags_classification(
entry_fields,
page_type,
)
)
return data