diff --git a/src/common/templates/403.html b/src/common/templates/403.html new file mode 100644 index 0000000..0512cd6 --- /dev/null +++ b/src/common/templates/403.html @@ -0,0 +1,5 @@ +{% extends "common/base.html" %} +{% block content %} +

Permission denied

+

You're not allowed to access this page.

+{% endblock %} diff --git a/src/common/templates/common/navbar.html b/src/common/templates/common/navbar.html index 654f20b..efd70a8 100644 --- a/src/common/templates/common/navbar.html +++ b/src/common/templates/common/navbar.html @@ -6,12 +6,12 @@ diff --git a/src/purchase/views.py b/src/purchase/views.py index ac0b8c4..b356ac0 100644 --- a/src/purchase/views.py +++ b/src/purchase/views.py @@ -17,6 +17,12 @@ class NewBasketView(ProtectedViewsMixin, SuccessMessageMixin, CreateView): form_class = BasketForm success_message = "Successfully created basket." + def get_success_url(self): + if self.request.user.has_perm("purchase.change_basket"): + return super().get_success_url() + else: + return reverse("purchase:new") + class UpdateBasketView(ProtectedViewsMixin, SuccessMessageMixin, UpdateView): permission_required = ["purchase.change_basket", "purchase.view_basket"]