mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow role checks to be bypassed for a given view
- Override the 'get_permission_model' attribute with None
This commit is contained in:
@ -79,6 +79,9 @@ class RolePermission(permissions.BasePermission):
|
||||
# Extract the model name associated with this request
|
||||
model = get_model_for_view(view)
|
||||
|
||||
if model is None:
|
||||
return True
|
||||
|
||||
app_label = model._meta.app_label
|
||||
model_name = model._meta.model_name
|
||||
|
||||
|
@ -154,6 +154,13 @@ class MeUserDetail(RetrieveUpdateAPI, UserDetail):
|
||||
"""Always return the current user object."""
|
||||
return self.request.user
|
||||
|
||||
def get_permission_model(self):
|
||||
"""Return the model for the permission check.
|
||||
|
||||
Note that for this endpoint, the current user can *always* edit their own details.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
class UserList(ListCreateAPI):
|
||||
"""List endpoint for detail on all users."""
|
||||
|
Reference in New Issue
Block a user