Browse Source

Remove ProjectMixin

pull/1627/head
Hironsan 2 years ago
parent
commit
ec69d34efb
2 changed files with 7 additions and 10 deletions
  1. 10
      backend/api/permissions.py
  2. 7
      backend/roles/permissions.py

10
backend/api/permissions.py

@ -1,13 +1,7 @@
from rest_framework.permissions import BasePermission
class ProjectMixin:
@classmethod
def get_project_id(cls, request, view):
return view.kwargs.get('project_id') or request.query_params.get('project_id')
class CanEditAnnotation(ProjectMixin, BasePermission):
class CanEditAnnotation(BasePermission):
def __init__(self, queryset):
super().__init__()
@ -21,7 +15,7 @@ class CanEditAnnotation(ProjectMixin, BasePermission):
return self.queryset.filter(id=annotation_id, user=request.user).exists()
class IsOwnComment(ProjectMixin, BasePermission):
class IsOwnComment(BasePermission):
@classmethod
def has_object_permission(cls, request, view, obj):
if request.user.is_superuser:

7
backend/roles/permissions.py

@ -2,15 +2,18 @@ from django.conf import settings
from django.db.models import Subquery
from rest_framework.permissions import BasePermission, SAFE_METHODS
from api.permissions import ProjectMixin
from .models import Member, Role
class RolePermission(ProjectMixin, BasePermission):
class RolePermission(BasePermission):
UNSAFE_METHODS = ('POST', 'PATCH', 'DELETE')
unsafe_methods_check = True
role_name = ''
@classmethod
def get_project_id(cls, request, view):
return view.kwargs.get('project_id') or request.query_params.get('project_id')
def has_permission(self, request, view):
if request.user.is_superuser:
return True

Loading…
Cancel
Save