Skip to content

Commit

Permalink
Adds all assigned group permissions to user
Browse files Browse the repository at this point in the history
  • Loading branch information
ridoo committed Oct 15, 2024
1 parent e54b42c commit 33c05c9
Showing 1 changed file with 14 additions and 8 deletions.
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

0 comments on commit 33c05c9

Please sign in to comment.