Commit 6ce4c005 by Nate Hardison

Raise exception if JABBER_DOMAIN not configured

Rather than checking to see if the JABBER_DOMAIN is not set and
continuing on, bail with an ImproperlyConfigured exception as soon
as we notice its absence.
parent 300eed24
...@@ -5,7 +5,7 @@ from functools import partial ...@@ -5,7 +5,7 @@ from functools import partial
from django.conf import settings from django.conf import settings
from django.core.context_processors import csrf from django.core.context_processors import csrf
from django.core.exceptions import PermissionDenied from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
...@@ -240,9 +240,7 @@ def chat_settings(course, user): ...@@ -240,9 +240,7 @@ def chat_settings(course, user):
""" """
domain = getattr(settings, "JABBER_DOMAIN", None) domain = getattr(settings, "JABBER_DOMAIN", None)
if domain is None: if domain is None:
log.warning('You must set JABBER_DOMAIN in the settings to ' raise ImproperlyConfigured("Missing JABBER_DOMAIN in the settings")
'enable the chat widget')
return None
return { return {
'domain': domain, 'domain': domain,
...@@ -327,17 +325,11 @@ def index(request, course_id, chapter=None, section=None, ...@@ -327,17 +325,11 @@ def index(request, course_id, chapter=None, section=None,
'xqa_server': settings.MITX_FEATURES.get('USE_XQA_SERVER', 'http://xqa:server@content-qa.mitx.mit.edu/xqa') 'xqa_server': settings.MITX_FEATURES.get('USE_XQA_SERVER', 'http://xqa:server@content-qa.mitx.mit.edu/xqa')
} }
# Only show the chat if it's enabled by the course and in the # Only show the chat if it's enabled both in the settings and
# settings. # by the course.
show_chat = course.show_chat and settings.MITX_FEATURES['ENABLE_CHAT'] context['show_chat'] = course.show_chat and settings.MITX_FEATURES.get('ENABLE_CHAT')
if show_chat: if context['show_chat']:
context['chat'] = chat_settings(course, user) context['chat'] = chat_settings(course, user)
# If we couldn't load the chat settings, then don't show
# the widget in the courseware.
if context['chat'] is None:
show_chat = False
context['show_chat'] = show_chat
chapter_descriptor = course.get_child_by(lambda m: m.url_name == chapter) chapter_descriptor = course.get_child_by(lambda m: m.url_name == chapter)
if chapter_descriptor is not None: if chapter_descriptor is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment