Commit ad36c1c6 authored by Skia's avatar Skia

Better handle 403 with next argument

parent a0f7150c
Pipeline #98 failed with stage
in 2 minutes and 21 seconds
{% extends "core/base.jinja" %}
{% extends "core/login.jinja" %}
{% block content %}
<h3>{% trans %}403, Forbidden{% endtrans %}</h3>
{{ super() }}
{% endblock %}
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Login{% endtrans %}
{% endblock %}
{% block content %}
{% if form.errors %}
......
......@@ -3,11 +3,13 @@ from django.shortcuts import render
from django.http import HttpResponseForbidden, HttpResponseNotFound
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
from django.views.generic.base import View
from django.contrib.auth.forms import AuthenticationForm
from core.models import Group
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):
return HttpResponseNotFound(render(request, "core/404.jinja"))
......
......@@ -35,13 +35,15 @@ class EbouticMain(TemplateView):
def get(self, request, *args, **kwargs):
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)
return super(EbouticMain, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
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)
if 'add_product' in request.POST['action']:
self.add_product(request)
......@@ -77,12 +79,14 @@ class EbouticCommand(TemplateView):
def get(self, request, *args, **kwargs):
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))
def post(self, request, *args, **kwargs):
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():
return HttpResponseRedirect(reverse_lazy('eboutic:main', args=self.args, kwargs=kwargs))
self.basket = Basket.objects.filter(id=request.session['basket_id']).first()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment