1 | from rest_framework import permissions |
||
0 ignored issues
–
show
|
|||
2 | from rest_framework.permissions import SAFE_METHODS |
||
3 | |||
4 | |||
5 | class CurrentUserOrAdmin(permissions.IsAuthenticated): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
6 | def has_object_permission(self, request, view, obj): |
||
7 | user = request.user |
||
8 | return user.is_staff or obj.pk == user.pk |
||
9 | |||
10 | |||
11 | class CurrentUserOrAdminOrReadOnly(permissions.IsAuthenticated): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
12 | def has_object_permission(self, request, view, obj): |
||
13 | user = request.user |
||
14 | if type(obj) == type(user) and obj == user: |
||
0 ignored issues
–
show
|
|||
15 | return True |
||
16 | return request.method in SAFE_METHODS or user.is_staff |
||
17 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.