def get_context_data(self, **kwargs): context = super(SearchView, self).get_context_data(**kwargs) params_dict = get_parsed_request(get_params=self.request.GET) query_Q = parse_to_q_object(self.request.GET, params_dict) context['members'] = MEMBER_MODEL.objects.filter( id__in=params_dict['members_ids']) context['parties'] = PARTY_MODEL.objects.filter( id__in=params_dict['parties_ids']) context['tags'] = Tag.objects.filter(id__in=params_dict['tags_ids']) context['search_str'] = params_dict['phrases'] context['excluded'] = Facebook_Status.objects.filter( status_id__in=params_dict['excluded']) context['search_title'] = ", ".join( [x for x in params_dict['phrases']]) or ", ".join( x.name for x in context['tags']) context['request_arguments'] = self.request. \ get_full_path().split('?')[-1] return_queryset = apply_request_params( Facebook_Status.objects.filter(query_Q), self.request) context['number_of_results'] = return_queryset.count() context['side_bar_parameter'] = HOURS_SINCE_PUBLICATION_FOR_SIDE_BAR return context
def get_context_data(self, **kwargs): context = super(SearchView, self).get_context_data(**kwargs) params_dict = get_parsed_request(get_params=self.request.GET) query_Q = parse_to_q_object(self.request.GET, params_dict) context['members'] = MEMBER_MODEL.objects.filter( id__in=params_dict['members_ids']) context['parties'] = PARTY_MODEL.objects.filter( id__in=params_dict['parties_ids']) context['tags'] = Tag.objects.filter(id__in=params_dict['tags_ids']) context['search_str'] = params_dict['phrases'] context['excluded'] = Facebook_Status.objects.filter( status_id__in=params_dict['excluded']) context['search_title'] = ", ".join([ x for x in params_dict['phrases'] ]) or ", ".join(x.name for x in context['tags']) context['request_arguments'] = self.request. \ get_full_path().split('?')[-1] return_queryset = apply_request_params( Facebook_Status.objects.filter(query_Q), self.request) context['number_of_results'] = return_queryset.count() context['side_bar_parameter'] = HOURS_SINCE_PUBLICATION_FOR_SIDE_BAR return context
def get_queryset(self): params_dict = get_parsed_request(get_params=self.request.GET) query_Q = parse_to_q_object(self.request.GET, params_dict) print 'get_queryset_executed:', query_Q return apply_request_params(Facebook_Status.objects.filter(query_Q), self.request)
def save_queryset_for_user(request): # print request.POST user = request.user qserializer = QSerializer(base64=True) query_params = unicode(request.POST.get('query').split('?')[-1]) query_dict = QueryDict(query_params.encode('utf8'), encoding='utf8') fake_request = HttpRequest() fake_request.GET = query_dict # print query_dict params_dict = get_parsed_request(query_dict) q_object = parse_to_q_object(query_dict, params_dict) dumped_queryset = qserializer.dumps(q_object) # print dumped_queryset title = request.POST.get('title') description = request.POST.get('description') q_object_date = filter_by_date(fake_request) # print q_object_date date_range = qserializer.dumps(q_object_date) order_by = json.dumps(get_order_by(fake_request)) # print title, description, date_range, order_by us, created = UserSearch.objects.get_or_create(user=user, title=title) if not created and us.user != request.user: return HttpResponse(content=json.dumps({'message': 'failure'}), content_type="application/json") raise Exception('User is not allowed to edit this query!') # print us us.queryset = dumped_queryset us.path = request.POST.get('query') us.order_by = order_by us.date_range = date_range us.description = description us.save() print us.queryset_dict return HttpResponse(content=json.dumps({'message': 'success'}), content_type="application/json")
def get_context_data(self, **kwargs): context = super(CustomView, self).get_context_data(**kwargs) sv = UserSearch.objects.get(id=self.kwargs['id']) qserialzer = QSerializer() query_filter = qserialzer.loads(sv.queryset) params_dict = get_parsed_request(get_params=self.request.GET) # context['members'] = MEMBER_MODEL.objects.filter(id__in=params_dict['members_ids']) # context['parties'] = PARTY_MODEL.objects.filter(id__in=params_dict['parties_ids']) # context['tags'] = Tag.objects.filter(id__in=params_dict['tags_ids']) # context['search_str'] = params_dict['phrases'] # context['search_title'] = ", ".join([x for x in params_dict['phrases']]) or ", ".join( # x.name for x in context['tags']) context['saved_query'] = sv return_queryset = apply_request_params(Facebook_Status.objects.filter(query_filter), self.request) context['number_of_results'] = return_queryset.count() context['side_bar_parameter'] = HOURS_SINCE_PUBLICATION_FOR_SIDE_BAR return context
def get_context_data(self, **kwargs): context = super(CustomView, self).get_context_data(**kwargs) sv = UserSearch.objects.get(id=self.kwargs['id']) qserialzer = QSerializer() query_filter = qserialzer.loads(sv.queryset) params_dict = get_parsed_request(get_params=self.request.GET) # context['members'] = MEMBER_MODEL.objects.filter(id__in=params_dict['members_ids']) # context['parties'] = PARTY_MODEL.objects.filter(id__in=params_dict['parties_ids']) # context['tags'] = Tag.objects.filter(id__in=params_dict['tags_ids']) # context['search_str'] = params_dict['phrases'] # context['search_title'] = ", ".join([x for x in params_dict['phrases']]) or ", ".join( # x.name for x in context['tags']) context['saved_query'] = sv return_queryset = apply_request_params( Facebook_Status.objects.filter(query_filter), self.request) context['number_of_results'] = return_queryset.count() context['side_bar_parameter'] = HOURS_SINCE_PUBLICATION_FOR_SIDE_BAR return context
def get_queryset(self): print(dir(self.request)) params_dict = get_parsed_request(get_params=self.request.GET) query_Q = parse_to_q_object(self.request.GET, params_dict) return apply_request_params(Facebook_Status.objects.filter(query_Q), self.request)
def get_queryset(self): params_dict = get_parsed_request(get_params=self.request.GET) query_Q = parse_to_q_object(self.request.GET, params_dict) # print 'get_queryset_executed:', query_Q return apply_request_params(Facebook_Status.objects.filter(query_Q), self.request)