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
--- /dev/null
+{% extends "base_content.html" %}
+{% load i18n %}
+{% block title %}{% trans "Not logged in" %}{% endblock %}
+{% block meta %}
+ <!-- <meta http-equiv="refresh" content="5;url={% url auth_signin %}"> -->
+{% endblock %}
+{% block forestyle%}
+ <style type="text/css">
+ form input { margin-right: 5px; }
+ </style>
+{% endblock %}
+{% block forejs %}
+ <script type="text/javascript">
+ $().ready(function(){
+ window.setInterval(function() {
+ $('#redirect_loader').html($('#redirect_loader').html() + '.')
+ }, 800);
+
+ window.setTimeout(function() {
+ window.location = "{% url auth_signin %}";
+ }, 5000);
+ });
+
+ </script>
+{% endblock %}
+{% block content %}
+<div id="main-bar" class="headNormal">
+ {% trans "Not logged in" %}
+</div>
+<div id="main-body" class="">
+ <div style="padding:5px 0px 10px 0;line-height:25px;">
+ <h3>{% trans "You are not logged in..." %}</h3>
+ <div style="margin-top:5px">
+ {% trans "...and the resource you're trying to access is pretocted." %}
+ <p>
+ {% trans "Redirecting to the login page." %}<span id="redirect_loader"></span>
+ </p>
+ <p>
+ {% trans "If you're not automatically redirected in 5 seconds, please click" %}
+ <a href="{% url auth_signin %}">{% trans "here" %}</a>.
+ </p>
+ </div>
+ </div>
+
+</div>
+{% endblock %}
\ No newline at end of file
form input { margin-right: 5px; }
</style>
{% endblock %}
-{% block forejs %}
- <script type="text/javascript">
- $().ready(function(){
- $("#linkPrevious").bind("click", back=function(){history.go(-1);})
- });
-
- </script>
-{% endblock %}
{% block content %}
<div id="main-bar" class="headNormal">
{% trans "Forbidden" %}
</div>
<div id="main-body" class="">
<div style="padding:5px 0px 10px 0;line-height:25px;">
- <h3>{% trans "Sorry, could not find the page you requested." %}</h3>
+ <h3>{% trans "Sorry, you don't have permissions to access this page." %}</h3>
<div style="margin-top:5px">
{% trans "This might have happened for the following reasons:" %}<br/>
<ul>
- <li>{% trans "this question or answer has been deleted;" %}</li>
- <li>{% trans "url has error - please check it;" %}</li>
- <li>{% trans "the page you tried to visit is protected or you don't have sufficient points, see" %} <a href="{% url faq %}"> faq</a>;</li>
- <li>{% trans "if you believe this error 404 should not have occurred, please" %}
- <a href="{{feedback_site_url}}" target="_blank">{% trans "report this problem" %}</a></li>
+ <li>{% trans "you followed a link on an email, but you're currently logged in as another user;" %}</li>
+ <li>{% trans "there are errors in the url, please confirm it;" %}</li>
+ <li>{% trans "if you believe you shouldn't bee seeing this error, please" %}
+ <a href="{% if settings.CONTACT_URL %}{{ settings.CONTACT_URL }}{% else %}{% url feedback %}{% endif %}" target="_blank">
+ {% trans "report this problem" %}
+ </a>
+ </li>
</ul>
</div>
- <script type="text/javascript">
- var GOOG_FIXURL_LANG = '{{settings.LANGUAGE_CODE}}';
- var GOOG_FIXURL_SITE = '{{site_url}}';
- </script>
- <script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
<ul>
- <li><a href="#" id="linkPrevious">{% trans "back to previous page" %} È</a></li>
- <li><a href="{% url questions %}">{% trans "see all questions" %} È</a></li>
- <li><a href="{% url tags %}">{% trans "see all tags" %} È</a></li>
+ <li><a href="{% url index %}">{% trans "to home page" %} »</a></li>
+ <li><a href="{% url questions %}">{% trans "see all questions" %} »</a></li>
+ <li><a href="{% url tags %}">{% trans "see all tags" %} »</a></li>
</ul>
</div>
<ul>
<li>{% trans "this question or answer has been deleted;" %}</li>
<li>{% trans "url has error - please check it;" %}</li>
- <li>{% trans "the page you tried to visit is protected or you don't have sufficient points, see" %} <a href="{% url faq %}"> faq</a>;</li>
<li>{% trans "if you believe this error 404 should not have occurred, please" %}
<a href="{{feedback_site_url}}" target="_blank">{% trans "report this problem" %}</a></li>
</ul>
</script>
<script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
<ul>
- <li><a href="#" id="linkPrevious">{% trans "back to previous page" %} »</a></li>
- <li><a href="{% url questions %}">{% trans "see all questions" %} »</a></li>
- <li><a href="{% url tags %}">{% trans "see all tags" %} »</a></li>
+ <li><a href="#" id="linkPrevious">{% trans "back to previous page" %} »</a></li>
+ <li><a href="{% url questions %}">{% trans "see all questions" %} »</a></li>
+ <li><a href="{% url tags %}">{% trans "see all tags" %} »</a></li>
</ul>
</div>
from django.shortcuts import render_to_response, get_object_or_404
from django.core.urlresolvers import reverse
-from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404
+from django.http import HttpResponseRedirect, HttpResponse, Http404
+from forum.http_responses import HttpResponseUnauthorized
from django.template import RequestContext
from django.utils.translation import ugettext as _
from django.utils import simplejson
if request.user.is_authenticated() and request.user.is_superuser:
return fn(request, *args, **kwargs)
else:
- return HttpResponseForbidden()
+ return HttpResponseUnauthorized(request)
return wrapper
from django.template import RequestContext
from django.core.urlresolvers import reverse
from forum.models import User
-from django.http import HttpResponseRedirect, Http404, HttpResponseForbidden
+from django.http import HttpResponseRedirect, Http404
+from forum.http_responses import HttpResponseUnauthorized
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
from django.utils.http import urlquote_plus
user_ = get_object_or_404(User, id=id)
if not (request.user.is_superuser or request.user == user_):
- return HttpResponseForbidden()
+ return HttpResponseUnauthorized(request)
auth_keys = user_.auth_keys.all()
def remove_external_provider(request, id):
association = get_object_or_404(AuthKeyUserAssociation, id=id)
if not (request.user.is_superuser or request.user == association.user):
- return HttpResponseForbidden()
+ return HttpResponseUnauthorized(request)
request.user.message_set.create(message=_("You removed the association with %s") % association.provider)
association.delete()
from forum import settings
from django.core.exceptions import ObjectDoesNotExist
from django.utils import simplejson
-from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, Http404
+from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import get_object_or_404, render_to_response
from django.utils.translation import ungettext, ugettext as _
from django.template import RequestContext
from urllib import unquote
from forum import settings as django_settings
from django.shortcuts import render_to_response, get_object_or_404
-from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404, HttpResponsePermanentRedirect
+from django.http import HttpResponseRedirect, HttpResponse, Http404, HttpResponsePermanentRedirect
from django.core.paginator import Paginator, EmptyPage, InvalidPage
from django.template import RequestContext
from django import template
from django.core.urlresolvers import reverse\r
from django.shortcuts import render_to_response, get_object_or_404\r
from django.template import RequestContext\r
-from django.http import HttpResponse, HttpResponseForbidden, HttpResponseRedirect, Http404\r
+from django.http import HttpResponse, HttpResponseRedirect, Http404\r
+from forum.http_responses import HttpResponseUnauthorized\r
from django.utils.translation import ugettext as _\r
from django.utils.http import urlquote_plus\r
from django.utils.html import strip_tags\r
def edit_user(request, id):\r
user = get_object_or_404(User, id=id)\r
if not (request.user.is_superuser or request.user == user):\r
- return HttpResponseForbidden()\r
+ return HttpResponseUnauthorized(request)\r
if request.method == "POST":\r
form = EditUserForm(user, request.POST)\r
if form.is_valid():\r
@login_required\r
def user_powers(request, id, action, status):\r
if not request.user.is_superuser:\r
- return HttpResponseForbidden()\r
+ return HttpResponseUnauthorized(request)\r
\r
user = get_object_or_404(User, id=id)\r
new_state = action == 'grant'\r
def decorated(request, id, slug=None):\r
user = get_object_or_404(User, id=id)\r
if private and not (user == request.user or request.user.is_superuser):\r
- return HttpResponseForbidden()\r
+ return HttpResponseUnauthorized(request)\r
context = fn(request, user)\r
\r
rev_page_title = user.username + " - " + page_title\r
from django.core.files.storage import FileSystemStorage
from django.shortcuts import render_to_response, get_object_or_404
from django.contrib.auth.decorators import login_required
-from django.http import HttpResponseRedirect, HttpResponse, HttpResponseForbidden, Http404
+from django.http import HttpResponseRedirect, HttpResponse, Http404
from django.template import RequestContext
from django.utils.html import *
from django.utils import simplejson