Browse Source
Merge pull request #1658 from doccano/enhancement/removeIsStaffPermission
Remove IsStaff permission
pull/1659/head
Hiroki Nakayama
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
11 deletions
-
backend/api/permissions.py
-
backend/api/views/project.py
|
|
@ -1,8 +0,0 @@ |
|
|
|
from rest_framework.permissions import BasePermission |
|
|
|
|
|
|
|
|
|
|
|
class IsStaff(BasePermission): |
|
|
|
def has_permission(self, request, view): |
|
|
|
if request.user.is_superuser or request.user.is_staff: |
|
|
|
return True |
|
|
|
return False |
|
|
@ -1,12 +1,11 @@ |
|
|
|
from django.conf import settings |
|
|
|
from rest_framework import generics, status |
|
|
|
from rest_framework.permissions import IsAuthenticated |
|
|
|
from rest_framework.permissions import IsAdminUser, IsAuthenticated |
|
|
|
from rest_framework.response import Response |
|
|
|
|
|
|
|
from members.permissions import IsInProjectReadOnlyOrAdmin |
|
|
|
|
|
|
|
from ..models import Project |
|
|
|
from ..permissions import IsStaff |
|
|
|
from ..serializers import ProjectPolymorphicSerializer |
|
|
|
|
|
|
|
|
|
|
@ -18,7 +17,7 @@ class ProjectList(generics.ListCreateAPIView): |
|
|
|
if self.request.method == 'GET': |
|
|
|
self.permission_classes = [IsAuthenticated, ] |
|
|
|
else: |
|
|
|
self.permission_classes = [IsAuthenticated & IsStaff] |
|
|
|
self.permission_classes = [IsAuthenticated & IsAdminUser] |
|
|
|
return super().get_permissions() |
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|