Add check for auditable groups.

To ensure functionality with other possible changes to group management.
This commit is contained in:
colcrunch 2018-07-22 19:38:56 -04:00
parent 4d4a9a27af
commit 1730bc3b98
2 changed files with 10 additions and 1 deletions

View File

@ -23,6 +23,15 @@ class GroupManager:
""" """
return not group.authgroup.internal return not group.authgroup.internal
@staticmethod
def auditable_group(group):
"""
Check if a group is auditable, i.e not an internal group
:param group: django.contrib.auth.models.Group object
:return: bool True if it is auditable, false otherwise
"""
return not group.authgroup.internal
@staticmethod @staticmethod
def has_management_permission(user): def has_management_permission(user):
return user.has_perm('auth.group_management') return user.has_perm('auth.group_management')

View File

@ -74,7 +74,7 @@ def group_membership_audit(request, group_id):
# Check its a joinable group i.e. not corp or internal # Check its a joinable group i.e. not corp or internal
# And the user has permission to manage it # And the user has permission to manage it
if not GroupManager.joinable_group(group) or not GroupManager.can_manage_group(request.user, group): if not GroupManager.auditable_group(group) or not GroupManager.can_manage_group(request.user, group):
logger.warning("User %s attempted to view the membership of group %s but permission was denied" % logger.warning("User %s attempted to view the membership of group %s but permission was denied" %
(request.user, group_id)) (request.user, group_id))
raise PermissionDenied raise PermissionDenied