Files
edx-platform/common/djangoapps/status/status.py
Anthony Wee 489c78dfa7 INCR-132: Run python-modernize on common/djangoapps/status (#20450)
* INCR-132: Run python-modernize on common/djangoapps/status

* isort

* isort migrations
2019-05-13 13:00:01 -04:00

31 lines
780 B
Python

"""
A tiny app that checks for a status message.
"""
from __future__ import absolute_import
import logging
from .models import GlobalStatusMessage
log = logging.getLogger(__name__)
def get_site_status_msg(course_key):
"""
Pull the status message from the database.
Caches the message by course.
"""
try:
# The current() value for GlobalStatusMessage is cached.
if not GlobalStatusMessage.current().enabled:
return None
return GlobalStatusMessage.current().full_message(course_key)
# Make as general as possible, because something broken here should not
# bring down the whole site.
except: # pylint: disable=bare-except
log.exception("Error while getting a status message.")
return None