X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/174c53e97bcf1e5412c141829d152aa5a2b8684c..ec62bc84aa89b5e946104bc4dcdf78f382c90165:/forum/http_responses.py diff --git a/forum/http_responses.py b/forum/http_responses.py index 42bef58..2ff4866 100644 --- a/forum/http_responses.py +++ b/forum/http_responses.py @@ -1,15 +1,41 @@ 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 + ) + +class HttpResponseNotFound(HttpResponse): + def __init__(self, request): + super(HttpResponseNotFound, self).__init__( + content=render_to_string('404.html', context_instance=RequestContext(request)), + status=404 + ) + +class HttpResponseIntServerError(HttpResponse): + def __init__(self, request): + super(HttpResponseIntServerError, self).__init__( + content=render_to_string('500.html', context_instance=RequestContext(request)), + status=500 + ) \ No newline at end of file