File tree Expand file tree Collapse file tree
contentcuration/contentcuration/viewsets Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from rest_framework import serializers
2121from rest_framework .decorators import action
2222from rest_framework .exceptions import ValidationError
23- from rest_framework .pagination import PageNumberPagination
2423from rest_framework .permissions import AllowAny
25- from rest_framework .permissions import IsAdminUser
2624from rest_framework .permissions import IsAuthenticated
2725from rest_framework .response import Response
2826from rest_framework .serializers import CharField
5250from contentcuration .viewsets .common import UUIDInFilter
5351from contentcuration .viewsets .sync .constants import CHANNEL
5452from contentcuration .viewsets .sync .utils import generate_update_event
53+ from contentcuration .viewsets .user import IsAdminUser
5554
5655
5756class ChannelListPagination (ValuesViewsetPageNumberPagination ):
Original file line number Diff line number Diff line change 1616from django_filters .rest_framework import FilterSet
1717from rest_framework .decorators import action
1818from rest_framework .exceptions import ValidationError
19- from rest_framework .permissions import IsAdminUser
19+ from rest_framework .permissions import BasePermission
2020from rest_framework .permissions import IsAuthenticated
2121from rest_framework .response import Response
2222
3939from contentcuration .viewsets .sync .constants import VIEWER_M2M
4040
4141
42+ class IsAdminUser (BasePermission ):
43+ """
44+ Our custom permission to check admin authorization.
45+ """
46+
47+ def has_permission (self , request , view ):
48+ try :
49+ return request .user and request .user .is_admin
50+ except AttributeError :
51+ return False
52+
53+
4254class UserListPagination (ValuesViewsetPageNumberPagination ):
4355 page_size = None
4456 page_size_query_param = "page_size"
You can’t perform that action at this time.
0 commit comments