Skip to content

Commit

Permalink
Fix is_site_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Dec 7, 2019
1 parent b046293 commit b01137f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions rdmo/accounts/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging

from django.conf import settings
from django.contrib.auth.models import User, Group, Permission
from django.contrib.auth.models import Group, Permission, User
from django.contrib.contenttypes.models import ContentType

from .models import Role
from .settings import GROUPS

log = logging.getLogger(__name__)
Expand All @@ -18,7 +19,13 @@ def get_full_name(user):

def is_site_manager(user):
if user.is_authenticated:
return user.role.manager.filter(pk=settings.SITE_ID).exists() | user.is_superuser
if user.is_superuser:
return True
else:
try:
return user.role.manager.filter(pk=settings.SITE_ID).exists()
except Role.DoesNotExist:
return False
else:
return False

Expand Down

0 comments on commit b01137f

Please sign in to comment.