From 2c63e6b6676f3ca49907493297b4fd77d53eb44c Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 20 Mar 2017 00:11:50 -0300 Subject: [PATCH 1/2] Use django.contrib.auth decorators --- gestioncof/decorators.py | 8 +------- kfet/decorators.py | 5 +---- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/gestioncof/decorators.py b/gestioncof/decorators.py index d7e70608..86bb2ff2 100644 --- a/gestioncof/decorators.py +++ b/gestioncof/decorators.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -from __future__ import division -from __future__ import print_function -from __future__ import unicode_literals - -from django_cas_ng.decorators import user_passes_test +from django.contrib.auth.decorators import user_passes_test def is_cof(user): @@ -15,8 +11,6 @@ def is_cof(user): return False cof_required = user_passes_test(lambda u: is_cof(u)) -cof_required_customdenied = user_passes_test(lambda u: is_cof(u), - login_url="cof-denied") def is_buro(user): diff --git a/kfet/decorators.py b/kfet/decorators.py index 9af9247f..46c41495 100644 --- a/kfet/decorators.py +++ b/kfet/decorators.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -from __future__ import (absolute_import, division, - print_function, unicode_literals) -from builtins import * +from django.contrib.auth.decorators import user_passes_test -from django_cas_ng.decorators import user_passes_test def kfet_is_team(user): return user.has_perm('kfet.is_team') From 5e802217fd1171f2bd72357f1285f83c7566e2d1 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 20 Mar 2017 20:24:44 -0300 Subject: [PATCH 2/2] Remove lambda operators --- gestioncof/decorators.py | 4 ++-- kfet/decorators.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gestioncof/decorators.py b/gestioncof/decorators.py index 86bb2ff2..a1263ce3 100644 --- a/gestioncof/decorators.py +++ b/gestioncof/decorators.py @@ -10,7 +10,7 @@ def is_cof(user): except: return False -cof_required = user_passes_test(lambda u: is_cof(u)) +cof_required = user_passes_test(is_cof) def is_buro(user): @@ -20,4 +20,4 @@ def is_buro(user): except: return False -buro_required = user_passes_test(lambda u: is_buro(u)) +buro_required = user_passes_test(is_buro) diff --git a/kfet/decorators.py b/kfet/decorators.py index 46c41495..0c8a1a76 100644 --- a/kfet/decorators.py +++ b/kfet/decorators.py @@ -6,4 +6,4 @@ from django.contrib.auth.decorators import user_passes_test def kfet_is_team(user): return user.has_perm('kfet.is_team') -teamkfet_required = user_passes_test(lambda u: kfet_is_team(u)) +teamkfet_required = user_passes_test(kfet_is_team)