Support pour les permissions globales
[auf_django_permissions.git] / auf / django / permissions / predicates.py
CommitLineData
03fab9eb
EMS
1# encoding: utf-8
2
3"""
4Builtin predicates.
5"""
6
7from auf.django.permissions import Predicate, predicate_for_perm, predicate_generator
8
9
10def has_global_perm(perm):
8f8c8a27 11 def p(user):
03fab9eb
EMS
12 return user.has_perm(perm)
13 return Predicate(p)
14
15def has_object_perm(perm):
16 def p(user, obj, cls):
8f8c8a27 17 return predicate_for_perm(perm, cls or obj.__class__)(user, obj, cls)
03fab9eb 18 return Predicate(p)