[#2711] setting AUF_PERMISSIONS_RULES
[auf_django_permissions.git] / auf / django / permissions / predicates.py
1 # encoding: utf-8
2
3 """
4 Builtin predicates.
5 """
6
7 from auf.django.permissions import Predicate, get_rules
8
9
10 def has_global_perm(perm):
11 def p(user):
12 return user.has_perm(perm)
13 return Predicate(p)
14
15 def has_object_perm(perm):
16 def p(user, obj, cls):
17 return get_rules().predicate_for_perm(perm, cls or obj.__class__)(user, obj, cls)
18 return Predicate(p)