def get_queryset(self): """ """ query = self.request.query_params.get('query') identity_uuid = self.kwargs['identity_uuid'] if not query: return ProviderMachine.objects.all() identity = Identity.objects.filter(uuid=identity_uuid).first() return search([CoreSearchProvider], identity, query)
def get_queryset(self): """ """ query = self.request.query_params.get('query') identity_uuid = self.kwargs['identity_uuid'] if not query: return ProviderMachine.objects.all() identity = Identity.objects.filter(uuid=identity_uuid).first() return search([CoreSearchProvider], identity, query)
def get_queryset(self): """""" query = self.request.QUERY_PARAMS.get('query') if not query: return CoreApplication.objects.all() identity = Identity.objects.filter( uuid=self.request.QUERY_PARAMS.get('identity')).first() # Okay to search w/ identity=None return search([CoreApplicationSearch], query, identity)
def get_queryset(self): """""" query = self.request.QUERY_PARAMS.get('query') if not query: return CoreApplication.objects.all() identity = Identity.objects.filter( uuid=self.request.QUERY_PARAMS.get('identity')).first() # Okay to search w/ identity=None return search([CoreApplicationSearch], query, identity)
def get_queryset(self): """ """ user = self.request.user query = self.request.QUERY_PARAMS.get("query") identity_uuid = self.kwargs["identity_uuid"] if not query: return ProviderMachine.objects.all() identity = Identity.objects.filter(uuid=identity_uuid).first() return search([CoreSearchProvider], identity, query)
def get(self, request, provider_uuid, identity_uuid): """ """ data = request.DATA user = get_first(User.objects.filter(username=request.user)) if not user: return failure_response(status.HTTP_401_UNAUTHORIZED, "User not found.") query = request.QUERY_PARAMS.get('query') if not query: return failure_response(status.HTTP_400_BAD_REQUEST, "Query not provided.") identity = get_first(Identity.objects.filter(uuid=identity_uuid)) if not identity: return failure_response(status.HTTP_400_BAD_REQUEST, 'Identity not provided,') search_result = search([CoreSearchProvider], identity, query) page = request.QUERY_PARAMS.get('page') if page or len(search_result) == 0: paginator = Paginator(search_result, 20, allow_empty_first_page=True) else: paginator = Paginator(search_result, len(search_result), allow_empty_first_page=True) try: search_page = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. search_page = paginator.page(1) except EmptyPage: # Page is out of range. # deliver last page of results. search_page = paginator.page(paginator.num_pages) serialized_data = PaginatedProviderMachineSerializer(search_page, context={ 'request': request }).data response = Response(serialized_data) response['Cache-Control'] = 'no-cache' return response
def get(self, request, provider_id, identity_id): """ """ data = request.DATA user = get_first(User.objects.filter(username=request.user)) if not user: return failure_response( status.HTTP_401_UNAUTHORIZED, "User not found.") query = request.QUERY_PARAMS.get('query') if not query: return failure_response( status.HTTP_400_BAD_REQUEST, "Query not provided.") identity = get_first(Identity.objects.filter(id=identity_id)) if not identity: return failure_response( status.HTTP_400_BAD_REQUEST, 'Identity not provided,') search_result = search([CoreSearchProvider], identity, query) page = request.QUERY_PARAMS.get('page') if page or len(search_result) == 0: paginator = Paginator(search_result, 20, allow_empty_first_page=True) else: paginator = Paginator(search_result, len(search_result), allow_empty_first_page=True) try: search_page = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. search_page = paginator.page(1) except EmptyPage: # Page is out of range. # deliver last page of results. search_page = paginator.page(paginator.num_pages) serialized_data = PaginatedProviderMachineSerializer( search_page, context={'request':request}).data response = Response(serialized_data) response['Cache-Control'] = 'no-cache' return response
def get(self, request): """""" query = request.QUERY_PARAMS.get('query') if not query: return failure_response(status.HTTP_400_BAD_REQUEST, "Query not provided.") identity_uuid = request.QUERY_PARAMS.get('identity') identity = Identity.objects.filter(uuid=identity_uuid) #Empty List or identity found.. if identity: identity = identity[0] #Okay to search w/ identity=None search_result = search([CoreApplicationSearch], query, identity) page = request.QUERY_PARAMS.get('page') if page or len(search_result) == 0: paginator = Paginator(search_result, 20, allow_empty_first_page=True) else: page = None paginator = Paginator(search_result, len(search_result), allow_empty_first_page=True) try: search_page = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. search_page = paginator.page(1) except EmptyPage: # Page is out of range. # deliver last page of results. search_page = paginator.page(paginator.num_pages) serialized_data = PaginatedApplicationSerializer(search_page, context={ 'request': request }).data response = Response(serialized_data) response['Cache-Control'] = 'no-cache' return response
def get(self, request): """""" data = request.DATA query = request.QUERY_PARAMS.get('query') if not query: return failure_response( status.HTTP_400_BAD_REQUEST, "Query not provided.") identity_id = request.QUERY_PARAMS.get('identity') identity = Identity.objects.filter(id=identity_id) #Empty List or identity found.. if identity: identity = identity[0] #Okay to search w/ identity=None search_result = search([CoreApplicationSearch], query, identity) page = request.QUERY_PARAMS.get('page') if page or len(search_result) == 0: paginator = Paginator(search_result, 20, allow_empty_first_page=True) else: page = None paginator = Paginator(search_result, len(search_result), allow_empty_first_page=True) try: search_page = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. search_page = paginator.page(1) except EmptyPage: # Page is out of range. # deliver last page of results. search_page = paginator.page(paginator.num_pages) serialized_data = PaginatedApplicationSerializer( search_page, context={'request':request}).data response = Response(serialized_data) response['Cache-Control'] = 'no-cache' return response