Add decorator to needed views

This commit is contained in:
Ludovic Stephan 2019-11-21 01:18:38 +01:00
parent c1a99453d5
commit a60df91b04
2 changed files with 16 additions and 3 deletions

View file

@ -30,9 +30,6 @@
</div> </div>
</div> </div>
{% include "kfet/form_field_snippet.html" with field=form.permissions %} {% include "kfet/form_field_snippet.html" with field=form.permissions %}
{% if not perms.kfet.manage_perms %}
{% include "kfet/form_authentication_snippet.html" %}
{% endif %}
{% include "kfet/form_submit_snippet.html" with value="Enregistrer" %} {% include "kfet/form_submit_snippet.html" with value="Enregistrer" %}
</form> </form>

View file

@ -24,6 +24,7 @@ from django.views.generic.edit import CreateView, DeleteView, UpdateView
from gestioncof.models import CofProfile from gestioncof.models import CofProfile
from kfet import KFET_DELETED_TRIGRAMME, consumers from kfet import KFET_DELETED_TRIGRAMME, consumers
from kfet.auth.decorators import kfet_password_auth
from kfet.config import kfet_config from kfet.config import kfet_config
from kfet.decorators import teamkfet_required from kfet.decorators import teamkfet_required
from kfet.forms import ( from kfet.forms import (
@ -119,6 +120,7 @@ def account_is_validandfree_ajax(request):
@login_required @login_required
@teamkfet_required @teamkfet_required
@kfet_password_auth
def account_create(request): def account_create(request):
# Enregistrement # Enregistrement
@ -320,6 +322,7 @@ def account_read(request, trigramme):
@login_required @login_required
@kfet_password_auth
def account_update(request, trigramme): def account_update(request, trigramme):
account = get_object_or_404(Account, trigramme=trigramme) account = get_object_or_404(Account, trigramme=trigramme)
@ -518,6 +521,7 @@ class CheckoutList(ListView):
# Checkout - Create # Checkout - Create
@method_decorator(kfet_password_auth, name="dispatch")
class CheckoutCreate(SuccessMessageMixin, CreateView): class CheckoutCreate(SuccessMessageMixin, CreateView):
model = Checkout model = Checkout
template_name = "kfet/checkout_create.html" template_name = "kfet/checkout_create.html"
@ -629,6 +633,7 @@ def getAmountBalance(data):
) )
@method_decorator(kfet_password_auth, name="dispatch")
class CheckoutStatementCreate(SuccessMessageMixin, CreateView): class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
model = CheckoutStatement model = CheckoutStatement
template_name = "kfet/checkoutstatement_create.html" template_name = "kfet/checkoutstatement_create.html"
@ -665,6 +670,7 @@ class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
return super().form_valid(form) return super().form_valid(form)
@method_decorator(kfet_password_auth, name="dispatch")
class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView): class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
model = CheckoutStatement model = CheckoutStatement
template_name = "kfet/checkoutstatement_update.html" template_name = "kfet/checkoutstatement_update.html"
@ -705,6 +711,7 @@ class CategoryList(ListView):
# Category - Update # Category - Update
@method_decorator(kfet_password_auth, name="dispatch")
class CategoryUpdate(SuccessMessageMixin, UpdateView): class CategoryUpdate(SuccessMessageMixin, UpdateView):
model = ArticleCategory model = ArticleCategory
template_name = "kfet/category_update.html" template_name = "kfet/category_update.html"
@ -959,6 +966,7 @@ def kpsul_checkout_data(request):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def kpsul_update_addcost(request): def kpsul_update_addcost(request):
addcost_form = AddcostForm(request.POST) addcost_form = AddcostForm(request.POST)
@ -996,6 +1004,7 @@ def get_missing_perms(required_perms, user):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def kpsul_perform_operations(request): def kpsul_perform_operations(request):
# Initializing response data # Initializing response data
data = {"operationgroup": 0, "operations": [], "warnings": {}, "errors": {}} data = {"operationgroup": 0, "operations": [], "warnings": {}, "errors": {}}
@ -1187,6 +1196,7 @@ def kpsul_perform_operations(request):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def kpsul_cancel_operations(request): def kpsul_cancel_operations(request):
# Pour la réponse # Pour la réponse
data = {"canceled": [], "warnings": {}, "errors": {}} data = {"canceled": [], "warnings": {}, "errors": {}}
@ -1545,6 +1555,7 @@ def transfers_create(request):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def perform_transfers(request): def perform_transfers(request):
data = {"errors": {}, "transfers": [], "transfergroup": 0} data = {"errors": {}, "transfers": [], "transfergroup": 0}
@ -1626,6 +1637,7 @@ def perform_transfers(request):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def cancel_transfers(request): def cancel_transfers(request):
# Pour la réponse # Pour la réponse
data = {"canceled": [], "warnings": {}, "errors": {}} data = {"canceled": [], "warnings": {}, "errors": {}}
@ -1739,6 +1751,7 @@ class InventoryList(ListView):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def inventory_create(request): def inventory_create(request):
articles = Article.objects.select_related("category").order_by( articles = Article.objects.select_related("category").order_by(
@ -1833,6 +1846,7 @@ class OrderList(ListView):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def order_create(request, pk): def order_create(request, pk):
supplier = get_object_or_404(Supplier, pk=pk) supplier = get_object_or_404(Supplier, pk=pk)
@ -1985,6 +1999,7 @@ class OrderRead(DetailView):
@teamkfet_required @teamkfet_required
@kfet_password_auth
def order_to_inventory(request, pk): def order_to_inventory(request, pk):
order = get_object_or_404(Order, pk=pk) order = get_object_or_404(Order, pk=pk)
@ -2092,6 +2107,7 @@ def order_to_inventory(request, pk):
) )
@method_decorator(kfet_password_auth, name="dispatch")
class SupplierUpdate(SuccessMessageMixin, UpdateView): class SupplierUpdate(SuccessMessageMixin, UpdateView):
model = Supplier model = Supplier
template_name = "kfet/supplier_form.html" template_name = "kfet/supplier_form.html"