Skip to content

Commit

Permalink
add resource base permissions (#7202) (#7205)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8454e63)

Co-authored-by: NAGGINDA MARTHA <marthamareal@gmail.com>
  • Loading branch information
Alessio Fabiani and marthamareal authored Mar 30, 2021
1 parent 5e4719e commit 1b50ad6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions geonode/security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def get_user_perms(self, user):
content_type_id=ctype.id,
user_id=user.id,
permission__codename__in=resource_perms
).values('permission__codename')
).values_list('permission__codename', flat=True)

return user_resource_perms

Expand All @@ -426,7 +426,8 @@ def user_can(self, user, permission):
if any(prefix in permission for prefix in perm_prefixes):
if config.read_only:
return False
user_perms = self.get_user_perms(user)
resource = self.get_self_resource()
user_perms = self.get_user_perms(user).union(resource.get_user_perms(user))
is_admin = user.is_superuser
is_staff = user.is_staff
is_owner = user == self.owner
Expand Down

0 comments on commit 1b50ad6

Please sign in to comment.