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

Fixed message views

parent e0c8ca67
No related branches found
No related tags found
No related merge requests found
...@@ -106,11 +106,11 @@ class Message: ...@@ -106,11 +106,11 @@ class Message:
return messages return messages
@staticmethod @staticmethod
def get_messages(): def get_messages(current_language=settings.VIPSLOGIC_LANGUAGE_CODE):
messages = [] messages = []
for item in Message.get_messages_as_json(): for item in Message.get_messages_as_json():
message = Message.get_instance_from_dict(item) message = Message.get_instance_from_dict(item, current_language)
messages.append(message) messages.append(message)
return messages return messages
...@@ -130,9 +130,9 @@ class Message: ...@@ -130,9 +130,9 @@ class Message:
return request_result.json() return request_result.json()
@staticmethod @staticmethod
def get_instance_from_dict(the_dict): def get_instance_from_dict(the_dict,current_language=settings.VIPSLOGIC_LANGUAGE_CODE):
message_locale = Message.get_message_locale(the_dict["messageLocaleSet"], settings.VIPSLOGIC_LANGUAGE_CODE) message_locale = Message.get_message_locale(the_dict["messageLocaleSet"], current_language)
message_illustration = Message.get_illustration(the_dict["messageIllustrationSet"], settings.VIPSLOGIC_LANGUAGE_CODE) message_illustration = Message.get_illustration(the_dict["messageIllustrationSet"], current_language)
created_by = "" created_by = ""
if message_locale.get("createdBy","") != "": if message_locale.get("createdBy","") != "":
created_by = "%s %s" %( created_by = "%s %s" %(
...@@ -143,9 +143,9 @@ class Message: ...@@ -143,9 +143,9 @@ class Message:
return Message( return Message(
the_dict["messageId"], the_dict["messageId"],
the_dict["organizationId"], the_dict["organizationId"],
message_locale.get("heading","MISSING HEADING FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE), message_locale.get("heading","MISSING HEADING FOR LOCALE '%s'" % current_language),
message_locale.get("leadParagraph","MISSING LEAD PARAGRAPH FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE), message_locale.get("leadParagraph","MISSING LEAD PARAGRAPH FOR LOCALE '%s'" % current_language),
message_locale.get("body","MISSING BODY TEXT FOR LOCALE '%s'" % settings.VIPSLOGIC_LANGUAGE_CODE), message_locale.get("body","MISSING BODY TEXT FOR LOCALE '%s'" % current_language),
datetime.strptime(the_dict["datePub"],settings.VIPSLOGIC_DATE_FORMAT) , datetime.strptime(the_dict["datePub"],settings.VIPSLOGIC_DATE_FORMAT) ,
datetime.strptime(the_dict["dateValidTo"],settings.VIPSLOGIC_DATE_FORMAT), datetime.strptime(the_dict["dateValidTo"],settings.VIPSLOGIC_DATE_FORMAT),
message_illustration.get("file_name", None), message_illustration.get("file_name", None),
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
# #
from django.shortcuts import render, get_object_or_404 from django.shortcuts import render, get_object_or_404
from django.utils import translation
from messages.models import Message from messages.models import Message
def index(request): def index(request):
context = { context = {
'messages' : Message.get_messages(), 'messages' : Message.get_messages(translation.get_language()),
} }
return render(request, 'messages/index.html', context) return render(request, 'messages/index.html', context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment