diff --git a/openedx/core/djangoapps/util/user_messages.py b/openedx/core/djangoapps/util/user_messages.py index 22ae96769d..3056df54f2 100644 --- a/openedx/core/djangoapps/util/user_messages.py +++ b/openedx/core/djangoapps/util/user_messages.py @@ -87,7 +87,7 @@ class UserMessageCollection(): raise NotImplementedError('Subclasses must define a namespace for messages.') @classmethod - def get_message_html(self, body_html, title=None, dismissable=False): + def get_message_html(self, body_html, title=None): """ Returns the entire HTML snippet for the message. @@ -96,32 +96,13 @@ class UserMessageCollection(): not use a title can just pass the body_html. """ if title: - title_area = Text(_('{header_open}{title}{header_close}')).format( + return Text(_('{header_open}{title}{header_close}{body}')).format( header_open=HTML('
') ) - else: - title_area = '' - if dismissable: - dismiss_button = HTML( - '' - ).format( - dismiss_text=Text(_("Dismiss")) - ) - else: - dismiss_button = '' - return Text('{title_area}{body_area}{dismiss_button}').format( - title_area=title_area, - body_area=HTML('').format( - body_html=body_html, - ), - dismiss_button=dismiss_button, - ) + return body_html @classmethod def register_user_message(self, request, message_type, body_html, **kwargs): @@ -202,6 +183,39 @@ class PageLevelMessages(UserMessageCollection): """ NAMESPACE = 'page_level_messages' + @classmethod + def get_message_html(self, body_html, title=None, dismissable=False): + """ + Returns the entire HTML snippet for the message. + """ + if title: + title_area = Text(_('{header_open}{title}{header_close}')).format( + header_open=HTML('') + ) + else: + title_area = '' + if dismissable: + dismiss_button = HTML( + '' + ).format( + dismiss_text=Text(_("Dismiss")) + ) + else: + dismiss_button = '' + return Text('{title_area}{body_area}{dismiss_button}').format( + title_area=title_area, + body_area=HTML('').format( + body_html=body_html, + ), + dismiss_button=dismiss_button, + ) + @classmethod def get_namespace(self): """