Merge pull request #19560 from edx/REVMI-2
add informational banners when masquerading as user who would not have access due to start date
This commit is contained in:
@@ -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):
|
||||
def get_message_html(cls, body_html, title=None, dismissable=False, **kwargs): # pylint: disable=unused-argument
|
||||
"""
|
||||
Returns the entire HTML snippet for the message.
|
||||
|
||||
@@ -105,7 +105,7 @@ class UserMessageCollection():
|
||||
return body_html
|
||||
|
||||
@classmethod
|
||||
def register_user_message(self, request, message_type, body_html, **kwargs):
|
||||
def register_user_message(cls, request, message_type, body_html, once_only=False, **kwargs):
|
||||
"""
|
||||
Register a message to be shown to the user in the next page.
|
||||
|
||||
@@ -114,10 +114,12 @@ class UserMessageCollection():
|
||||
body_html (str): body of the message in html format
|
||||
title (str): optional title for the message as plain text
|
||||
dismissable (bool): shows a dismiss button (defaults to no button)
|
||||
once_only (bool): show the message only once per request
|
||||
"""
|
||||
assert isinstance(message_type, UserMessageType)
|
||||
message = Text(self.get_message_html(body_html, **kwargs))
|
||||
messages.add_message(request, message_type.value, Text(message), extra_tags=self.get_namespace())
|
||||
message = Text(cls.get_message_html(body_html, **kwargs))
|
||||
if not once_only or message not in [m.message for m in messages.get_messages(request)]:
|
||||
messages.add_message(request, message_type.value, Text(message), extra_tags=cls.get_namespace())
|
||||
|
||||
@classmethod
|
||||
def register_info_message(self, request, message, **kwargs):
|
||||
@@ -184,7 +186,7 @@ class PageLevelMessages(UserMessageCollection):
|
||||
NAMESPACE = 'page_level_messages'
|
||||
|
||||
@classmethod
|
||||
def get_message_html(self, body_html, title=None, dismissable=False):
|
||||
def get_message_html(cls, body_html, title=None, dismissable=False, **kwargs):
|
||||
"""
|
||||
Returns the entire HTML snippet for the message.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user