[#2711] setting AUF_PERMISSIONS_RULES
[auf_django_permissions.git] / auf / django / permissions / predicates.py
CommitLineData
03fab9eb
EMS
1# encoding: utf-8
2
3"""
4Builtin predicates.
5"""
6
3e56a4a6 7from auf.django.permissions import Predicate, get_rules
03fab9eb
EMS
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):
3e56a4a6 17 return get_rules().predicate_for_perm(perm, cls or obj.__class__)(user, obj, cls)
03fab9eb 18 return Predicate(p)