]> git.openstreetmap.org Git - osqa.git/blob - forum/http_responses.py
Better fix that the last one.
[osqa.git] / forum / http_responses.py
1 from django.http import HttpResponse
2 from django.template.loader import render_to_string
3 from django.template import RequestContext
4
5 from forum import settings
6
7 class HttpResponseServiceUnavailable(HttpResponse):
8     def __init__(self, message):
9         super(HttpResponseServiceUnavailable, self).__init__(
10             content=render_to_string('503.html', {
11                 'message': message,
12                 'app_logo': settings.APP_LOGO,
13                 'app_title': settings.APP_TITLE
14             }), status=503)
15
16 class HttpResponseUnauthorized(HttpResponse):
17     def __init__(self, request):
18         if request.user.is_authenticated():
19             super(HttpResponseUnauthorized, self).__init__(
20                 content=render_to_string('403.html', context_instance=RequestContext(request)),
21                 status=403
22             )
23         else:
24             super(HttpResponseUnauthorized, self).__init__(
25                 content=render_to_string('401.html', context_instance=RequestContext(request)),
26                 status=401
27             )
28
29 class HttpResponseNotFound(HttpResponse):
30     def __init__(self, request):
31         super(HttpResponseNotFound, self).__init__(
32             content=render_to_string('404.html', context_instance=RequestContext(request)),
33             status=404
34         )
35
36 class HttpResponseIntServerError(HttpResponse):
37     def __init__(self, request):
38         super(HttpResponseIntServerError, self).__init__(
39             content=render_to_string('500.html', context_instance=RequestContext(request)),
40             status=500
41         )