status.py 740 Bytes
Newer Older
1 2 3 4 5
"""
A tiny app that checks for a status message.
"""

import logging
6 7

from .models import GlobalStatusMessage
8 9 10

log = logging.getLogger(__name__)

Calen Pennington committed
11

12
def get_site_status_msg(course_key):
13
    """
14
    Pull the status message from the database.
15

16
    Caches the message by course.
17 18
    """
    try:
19 20
        # The current() value for GlobalStatusMessage is cached.
        if not GlobalStatusMessage.current().enabled:
21 22
            return None

23 24 25 26
        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
27
        log.exception("Error while getting a status message.")
28
        return None