def get(self, request): """Provide access data for principal.""" app = request.query_params.get(APPLICATION_KEY) principal = get_principal_from_request(request) cache = AccessCache(request.tenant.schema_name) access_policy = cache.get_policy(principal.uuid, app) if access_policy is None: queryset = self.get_queryset() access_policy = self.serializer_class(queryset, many=True).data cache.save_policy(principal.uuid, app, access_policy) page = self.paginate_queryset(access_policy) if page is not None: return self.get_paginated_response(access_policy) return Response({"data": access_policy})
def get(self, request): """Provide access data for principal.""" validate_limit_and_offset(request.query_params) sub_key = self.generate_sub_key(request) principal = get_principal_from_request(request) cache = AccessCache(request.tenant.schema_name) access_policy = cache.get_policy(principal.uuid, sub_key) if access_policy is None: queryset = self.get_queryset() page = self.paginate_queryset(queryset) access_policy = self.serializer_class(page, many=True).data cache.save_policy(principal.uuid, sub_key, access_policy) if self.paginate_queryset(access_policy) is not None: return self.get_paginated_response(access_policy) return Response({"data": access_policy})
def get(self, request): """Provide access data for principal.""" # Parameter extraction sub_key, ordering = self.validate_and_get_param(request.query_params) principal = get_principal_from_request(request) cache = AccessCache(request.tenant.schema_name) access_policy = cache.get_policy(principal.uuid, sub_key) if access_policy is None: queryset = self.get_queryset(ordering) access_policy = self.serializer_class(queryset, many=True).data cache.save_policy(principal.uuid, sub_key, access_policy) page = self.paginate_queryset(access_policy) if page is not None: return self.get_paginated_response(page) return Response({"data": access_policy})