diff --git a/lms/djangoapps/django_comment_client/forum/views.py b/lms/djangoapps/django_comment_client/forum/views.py index 55797227ea..b04bd787d8 100644 --- a/lms/djangoapps/django_comment_client/forum/views.py +++ b/lms/djangoapps/django_comment_client/forum/views.py @@ -174,6 +174,9 @@ def forum_form_discussion(request, course_id): try: unsafethreads, query_params = get_threads(request, course_id) # This might process a search query threads = [utils.safe_content(thread) for thread in unsafethreads] + except (cc.utils.CommentClientMaintenanceError) as err: + log.warning("Forum is in maintenance mode") + return render_to_response('discussion/maintenance.html', {}) except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError) as err: log.error("Error loading forum discussion threads: %s" % str(err)) raise Http404 diff --git a/lms/lib/comment_client/utils.py b/lms/lib/comment_client/utils.py index 1ce03ed3c7..203e752a05 100644 --- a/lms/lib/comment_client/utils.py +++ b/lms/lib/comment_client/utils.py @@ -55,6 +55,9 @@ def perform_request(method, url, data_or_params=None, *args, **kwargs): if 200 < response.status_code < 500: raise CommentClientError(response.text) + # Heroku returns a 503 when an application is in maintenance mode + elif response.status_code == 503: + raise CommentClientMaintenanceError(response.text) elif response.status_code == 500: raise CommentClientUnknownError(response.text) else: @@ -72,5 +75,9 @@ class CommentClientError(Exception): return repr(self.message) +class CommentClientMaintenanceError(CommentClientError): + pass + + class CommentClientUnknownError(CommentClientError): pass diff --git a/lms/templates/discussion/maintenance.html b/lms/templates/discussion/maintenance.html new file mode 100644 index 0000000000..a0f57cdfb3 --- /dev/null +++ b/lms/templates/discussion/maintenance.html @@ -0,0 +1,3 @@ +<%inherit file="../main.html" /> +
The forums are currently undergoing maintenance. We'll have them back up shortly!