]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/http_responses.py
Adds better permalinks to answers, computing the position of an answer in the list.
[osqa.git] / forum / http_responses.py
index 42bef588814b98c3437917470a6e71882ae166d8..7fae3b69f3bd63b9d60fc93f91b733633e8af2a8 100644 (file)
@@ -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