docs(views): update to denote dynamic permissions

ref: #248 #345 #374
This commit is contained in:
2024-11-01 18:49:21 +09:30
parent a04cfeef86
commit 429f3a9a94

View File

@ -35,6 +35,32 @@ Views are used with Centurion ERP to Fetch the data for rendering.
- Model VieSets must be tested against tests `from api.tests.abstract.viewsets import ViewSetModel`
## Permissions
If you wish to deviate from the standard CRUD permissions, define a function called `get_dynamic_permissions` within the `view`/`ViewSet`. The function must return a list of permissions. This is useful if you have added additional permissions to a model.
Example of the function `get_dynamic_permissions`
``` py
def get_dynamic_permissions(self):
if self.action == 'create':
self.permission_required = [
'core.random_permission_name',
]
else:
raise ValueError('unable to determine the action_keyword')
return super().get_permission_required()
```
## Pre v1.3 Docs
!!! warning