X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/174c53e97bcf1e5412c141829d152aa5a2b8684c..e14bec1444b50a351b0d228d25f6d6cf56a8151c:/forum/http_responses.py diff --git a/forum/http_responses.py b/forum/http_responses.py index 42bef58..7fae3b6 100644 --- a/forum/http_responses.py +++ b/forum/http_responses.py @@ -1,15 +1,27 @@ from django.http import HttpResponse from django.template.loader import render_to_string +from django.template import RequestContext from forum import settings class HttpResponseServiceUnavailable(HttpResponse): def __init__(self, message): - super(HttpResponseServiceUnavailable, self).__init__(content=render_to_string('503.html', { - 'message': message, - 'app_logo': settings.APP_LOGO, - 'app_title': settings.APP_TITLE - }), status=503) + super(HttpResponseServiceUnavailable, self).__init__( + content=render_to_string('503.html', { + 'message': message, + 'app_logo': settings.APP_LOGO, + 'app_title': settings.APP_TITLE + }), status=503) class HttpResponseUnauthorized(HttpResponse): - pass \ No newline at end of file + def __init__(self, request): + if request.user.is_authenticated(): + super(HttpResponseUnauthorized, self).__init__( + content=render_to_string('403.html', context_instance=RequestContext(request)), + status=403 + ) + else: + super(HttpResponseUnauthorized, self).__init__( + content=render_to_string('401.html', context_instance=RequestContext(request)), + status=401 + ) \ No newline at end of file