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

from django.conf import settings
import logging
7 8

from .models import GlobalStatusMessage
9 10 11

log = logging.getLogger(__name__)

Calen Pennington committed
12

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

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

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