diff --git a/backend/api/permissions.py b/backend/api/permissions.py index 985de1ef..ad70faf6 100644 --- a/backend/api/permissions.py +++ b/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: diff --git a/backend/roles/permissions.py b/backend/roles/permissions.py index be3a33cb..31c49717 100644 --- a/backend/roles/permissions.py +++ b/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