mirror of
https://github.com/solero/houdini.git
synced 2024-11-24 14:37:22 +00:00
Wrapper functions for registering and unregistering permissions
This commit is contained in:
parent
8e33779ed8
commit
38e4a1e0fa
@ -21,6 +21,18 @@ class PermissionCollection(AbstractDataCollection):
|
|||||||
__indexby__ = 'name'
|
__indexby__ = 'name'
|
||||||
__filterby__ = 'name'
|
__filterby__ = 'name'
|
||||||
|
|
||||||
|
async def register(self, permission_name):
|
||||||
|
permission_parts = permission_name.split('.')
|
||||||
|
for permission_index in range(1, len(permission_parts) + 1):
|
||||||
|
permission_name = '.'.join(permission_parts[:permission_index])
|
||||||
|
if permission_name not in self:
|
||||||
|
await self.insert(name=permission_name)
|
||||||
|
|
||||||
|
async def unregister(self, permission_name):
|
||||||
|
for permission in self.values():
|
||||||
|
if permission.name == permission_name or permission.name.startswith(permission_name):
|
||||||
|
await self.delete(permission.name)
|
||||||
|
|
||||||
|
|
||||||
class PenguinPermissionCollection(AbstractDataCollection):
|
class PenguinPermissionCollection(AbstractDataCollection):
|
||||||
__model__ = PenguinPermission
|
__model__ = PenguinPermission
|
||||||
|
Loading…
Reference in New Issue
Block a user