Commit 5b0d6a9c authored by ∞'s avatar 💻

Improve case detection

This improves compatibility with more standard has_perm calls.
parent 8e2fb50e
......@@ -5,16 +5,25 @@ class ViewBackend:
"""
return None
def has_perm(self, user_obj, perm, obj=None):
if not obj.authenticate:
return True
def has_perm(self, user_obj, perm, obj=None): # noqa
try:
if not obj.authenticate:
return True
except AttributeError:
return False
elif not user_obj.is_authenticated:
if not user_obj.is_authenticated:
return False
if user_obj.is_superuser or obj.allowed_groups == 'any':
if user_obj.is_superuser:
return True
try:
if obj.allowed_groups == 'any':
return True
except AttributeError:
return False
for group in user_obj.groups.all():
if group.name in obj.allowed_groups:
return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment