mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Better handle 403 with next argument
This commit is contained in:
parent
a0f7150c55
commit
ad36c1c6f6
@ -1,8 +1,10 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/login.jinja" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>{% trans %}403, Forbidden{% endtrans %}</h3>
|
<h3>{% trans %}403, Forbidden{% endtrans %}</h3>
|
||||||
|
|
||||||
|
{{ super() }}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
{% extends "core/base.jinja" %}
|
{% extends "core/base.jinja" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}Login{% endtrans %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% if form.errors %}
|
{% if form.errors %}
|
||||||
|
@ -3,11 +3,13 @@ from django.shortcuts import render
|
|||||||
from django.http import HttpResponseForbidden, HttpResponseNotFound
|
from django.http import HttpResponseForbidden, HttpResponseNotFound
|
||||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||||
from django.views.generic.base import View
|
from django.views.generic.base import View
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
|
|
||||||
from core.models import Group
|
from core.models import Group
|
||||||
|
|
||||||
def forbidden(request):
|
def forbidden(request):
|
||||||
return HttpResponseForbidden(render(request, "core/403.jinja"))
|
return HttpResponseForbidden(render(request, "core/403.jinja", context={'next': request.path, 'form':
|
||||||
|
AuthenticationForm()}))
|
||||||
|
|
||||||
def not_found(request):
|
def not_found(request):
|
||||||
return HttpResponseNotFound(render(request, "core/404.jinja"))
|
return HttpResponseNotFound(render(request, "core/404.jinja"))
|
||||||
|
@ -35,13 +35,15 @@ class EbouticMain(TemplateView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
|
request.path)
|
||||||
self.make_basket(request)
|
self.make_basket(request)
|
||||||
return super(EbouticMain, self).get(request, *args, **kwargs)
|
return super(EbouticMain, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
|
request.path)
|
||||||
self.make_basket(request)
|
self.make_basket(request)
|
||||||
if 'add_product' in request.POST['action']:
|
if 'add_product' in request.POST['action']:
|
||||||
self.add_product(request)
|
self.add_product(request)
|
||||||
@ -77,12 +79,14 @@ class EbouticCommand(TemplateView):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
|
request.path)
|
||||||
return HttpResponseRedirect(reverse_lazy('eboutic:main', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('eboutic:main', args=self.args, kwargs=kwargs))
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
if not request.user.is_authenticated():
|
if not request.user.is_authenticated():
|
||||||
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('core:login', args=self.args, kwargs=kwargs) + "?next=" +
|
||||||
|
request.path)
|
||||||
if 'basket_id' not in request.session.keys():
|
if 'basket_id' not in request.session.keys():
|
||||||
return HttpResponseRedirect(reverse_lazy('eboutic:main', args=self.args, kwargs=kwargs))
|
return HttpResponseRedirect(reverse_lazy('eboutic:main', args=self.args, kwargs=kwargs))
|
||||||
self.basket = Basket.objects.filter(id=request.session['basket_id']).first()
|
self.basket = Basket.objects.filter(id=request.session['basket_id']).first()
|
||||||
|
Loading…
Reference in New Issue
Block a user