3030from core .common .search import CustomESSearch
3131from core .common .serializers import RootSerializer
3232from core .common .swagger_parameters import all_resource_query_param
33+ from core .common .throttling import ThrottleUtil
3334from core .common .utils import compact_dict_by_values , to_snake_case , parse_updated_since_param , \
3435 to_int , get_falsy_values , get_truthy_values , format_url_for_search
3536from core .concepts .permissions import CanViewParentDictionary , CanEditParentDictionary
@@ -59,6 +60,9 @@ class BaseAPIView(generics.GenericAPIView, PathWalkerMixin):
5960 facet_class = None
6061 total_count = 0
6162
63+ def get_throttles (self ):
64+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
65+
6266 def has_no_kwargs (self ):
6367 return len (self .kwargs .values ()) == 0
6468
@@ -913,6 +917,9 @@ def __set_params(self):
913917class SourceChildExtrasBaseView :
914918 default_qs_sort_attr = '-created_at'
915919
920+ def get_throttles (self ):
921+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
922+
916923 def get_object (self ):
917924 queryset = self .get_queryset ()
918925
@@ -980,6 +987,9 @@ class APIVersionView(APIView): # pragma: no cover
980987 permission_classes = (AllowAny ,)
981988 swagger_schema = None
982989
990+ def get_throttles (self ):
991+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
992+
983993 @staticmethod
984994 def get (_ ):
985995 return Response (__version__ )
@@ -989,6 +999,9 @@ class ChangeLogView(APIView): # pragma: no cover
989999 permission_classes = (AllowAny , )
9901000 swagger_schema = None
9911001
1002+ def get_throttles (self ):
1003+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
1004+
9921005 @staticmethod
9931006 def get (_ ):
9941007 resp = requests .get ('https://raw.githubusercontent.com/OpenConceptLab/oclapi2/master/changelog.md' )
@@ -1043,6 +1056,9 @@ def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
10431056class FeedbackView (APIView ): # pragma: no cover
10441057 permission_classes = (AllowAny , )
10451058
1059+ def get_throttles (self ):
1060+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
1061+
10461062 @staticmethod
10471063 @swagger_auto_schema (request_body = openapi .Schema (
10481064 type = openapi .TYPE_OBJECT ,
@@ -1141,6 +1157,9 @@ class AbstractChecksumView(APIView):
11411157 permission_classes = (IsAuthenticated ,)
11421158 smart = False
11431159
1160+ def get_throttles (self ):
1161+ return ThrottleUtil .get_throttles_by_user_plan (self .request .user )
1162+
11441163 @swagger_auto_schema (
11451164 manual_parameters = [all_resource_query_param ],
11461165 request_body = openapi .Schema (
0 commit comments