Skip to content
Snippets Groups Projects
Commit b9b020d6 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added fallback for message if requested locale version is not present

parent eb522ddd
No related branches found
No related tags found
No related merge requests found
......@@ -125,9 +125,9 @@ class Message:
return Message(
the_dict["messageId"],
the_dict["organizationId"],
message_locale["heading"],
message_locale["leadParagraph"],
message_locale["body"],
message_locale.get("heading","MISSING HEADING FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE),
message_locale.get("leadParagraph","MISSING LEAD PARAGRAPH FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE),
message_locale.get("body","MISSING BODY TEXT FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE),
the_dict["datePub"],
the_dict["dateValidTo"],
message_illustration.get("file_name", None),
......@@ -139,6 +139,11 @@ class Message:
for message_locale in message_locale_set:
if message_locale["messageLocalePK"]["locale"] == language:
return message_locale
# Fallback: Return the first locale in the set
if len(message_locale_set) > 0:
return message_locale_set[0]
else:
return {}
@staticmethod
def get_illustration(message_illustration_set, language):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment