924a8a602f6f8c44c9a86d9aa6eb87be04334bbf
[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, predicate_for_perm, predicate_generator
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 predicate_for_perm(perm, cls or obj.__class__)(user, obj, cls)
18 return Predicate(p)