Issues (463)

djoser/permissions.py (4 issues)

1
from rest_framework import permissions
0 ignored issues
show
This module 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.

Loading history...
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.

Loading history...
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.

Loading history...
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
Using type() instead of isinstance() for a typecheck.
Loading history...
15
            return True
16
        return request.method in SAFE_METHODS or user.is_staff
17