change get_permissions to return list#500
Conversation
|
I found a case that supports def get_permissions(self) -> Sequence[_SupportsHasPermission]:
if self.action == 'list':
return [OR(IsAdminUser(), SomeOtherPermission())]
return super().get_permissions() |
59fefcc to
5977c99
Compare
60422fb to
d8bee67
Compare
|
I had to revert back to |
|
Thanks. I'll have a look in the evening. (feel free to ping if I forget) I'm not using the DRF permission system myself, so I'm not very familiar with it. Is it worth investigating support for boolean operators as well, e.g. |
|
The |
I have made things!
Proposal to change the signature of
get_permissionstolist[BasePermission]. This allows one to customize the permissions of a view as suggested by the documentation: https://www.django-rest-framework.org/api-guide/permissions/#overview-of-access-restriction-methodsThe source code also suggests that is is a
list:https://github.com/encode/django-rest-framework/blob/f56b85b7dd7e4f786e0769bba6b7609d4507da83/rest_framework/views.py#L278
It was originally changed in #320 to
Sequence[_SupportsHasPermission].I am not sure if the element type has to be_SupportsHasPermissioninstead ofBasePermission. All the other method signatures use the base type.Update: In the end I reverted back for the same reason why the return type was changed to
Sequencein #320 and added a few more test cases.Related issues
Refs #319 (PR: #320)