Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fixes #12639] Adds all assigned group permissions to user #12640

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions geonode/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,22 @@ def location(self):

@property
def perms(self):
perms = set()
if self.is_superuser or self.is_staff:
# return all permissions for admins
perms = PERMISSIONS.values()
else:
user_groups = self.groups.values_list("name", flat=True)
group_perms = (
Permission.objects.filter(group__name__in=user_groups).distinct().values_list("codename", flat=True)
)
# return constant names defined by GeoNode
perms = [PERMISSIONS[db_perm] for db_perm in group_perms]
perms.update(PERMISSIONS.values())

user_groups = self.groups.values_list("name", flat=True)
group_perms = (
Permission.objects.filter(group__name__in=user_groups).distinct().values_list("codename", flat=True)
)
for p in group_perms:
if p in PERMISSIONS:
# return constant names defined by GeoNode
perms.add(PERMISSIONS[p])
else:
# add custom permissions
perms.add(p)

# check READ_ONLY mode
config = Configuration.load()
Expand Down
Loading