def add_perm self perm if self has_perm perm return if perm in _custom

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
def add_perm(self, perm):
if self.has_perm(perm):
return
if perm in _custom_permissions:
p = _custom_permissions[perm]
if hasattr(p, 'add_permission'):
p.add_permission(user)
self._cache_perm(perm)
else:
try:
p = Permission.objects.get(codename=perm)
self.permissions.add(p)
self._cache_perm(perm)
except Permission.DoesNotExist:
pass