]> git.openstreetmap.org Git - osqa.git/blob - forum/http_responses.py
Improves the answer position guessing.
[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             )