mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-03 21:21:14 -04:00
Split (has_)permissions_for_service method
This avoids duplicating the code to get user permissions ("admin
roles") for a service, which we'll need in the next commit.
This commit is contained in:
@@ -215,8 +215,7 @@ class User(JSONModel, UserMixin):
|
||||
return True
|
||||
|
||||
if any(
|
||||
self.has_permission_for_service(service_id, permission)
|
||||
for permission in permissions
|
||||
self.permissions_for_service(service_id) & set(permissions)
|
||||
):
|
||||
return True
|
||||
|
||||
@@ -226,6 +225,9 @@ class User(JSONModel, UserMixin):
|
||||
Service.from_id(service_id).organisation_id
|
||||
)
|
||||
|
||||
def permissions_for_service(self, service_id):
|
||||
return self._permissions.get(service_id, set())
|
||||
|
||||
def has_permission_for_service(self, service_id, permission):
|
||||
return permission in self._permissions.get(service_id, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user