Beispiel #1
0
 def get_queryset(self, **kwargs):
     sv = get_object_or_404(UserSearch, id=self.kwargs['id'])
     # sv = UserSearch.objects.get(id=self.kwargs['id'])
     qserialzer = QSerializer()
     query_filter = qserialzer.loads(sv.queryset)
     return apply_request_params(
         Facebook_Status.objects.filter(query_filter), self.request)
Beispiel #2
0
 def get_queryset(self, **kwargs):
     sv = get_object_or_404(UserSearch, id=self.kwargs['id'])
     # sv = UserSearch.objects.get(id=self.kwargs['id'])
     qserialzer = QSerializer()
     query_filter = qserialzer.loads(sv.queryset)
     return apply_request_params(
         Facebook_Status.objects.filter(query_filter), self.request)
Beispiel #3
0
    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)

        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'] = (
            params.HOURS_SINCE_PUBLICATION_FOR_SIDE_BAR)

        return context
Beispiel #4
0
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")
Beispiel #5
0
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")
Beispiel #6
0
    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
Beispiel #7
0
    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
Beispiel #8
0
 def date_range_dict(self):
     return self.date_range and QSerializer(base64=True).loads(
         self.date_range).__dict__
Beispiel #9
0
 def queryset_dict(self):
     return self.queryset and QSerializer(base64=True).loads(
         self.queryset).__dict__