Beispiel #1
0
    def filters_data(request, queryset):
        search_name = request.GET.get('search_name', None)
        person_name = request.GET.getlist('person_name', None)
        cate_name = request.GET.getlist('cate_name', None)
        occup_name = request.GET.getlist('cate_name', None)
        paid_name = request.GET.getlist('paid_name', None)
        date_start, date_end, date_range = initial_date(request, 6)

        queryset = queryset.filter(date_expired__range=[date_start, date_end]
                                   ) if date_start and date_end else queryset
        queryset = queryset.filter(is_paid=True) if 'paid' in paid_name else queryset.filter(is_paid=False) \
            if 'not_' in paid_name else queryset
        queryset = queryset.filter(
            category__in=cate_name) if cate_name else queryset
        queryset = queryset.filter(
            person__id__in=person_name) if person_name else queryset
        queryset = queryset.filter(
            person__occupation__id__in=occup_name) if occup_name else queryset
        queryset = queryset.filter(
            Q(title__icontains=search_name)
            | Q(person__title__icontains=search_name)
            | Q(person__occupation__title__icontains=search_name)).distict(
            ) if search_name else queryset

        return queryset
Beispiel #2
0
    def filters_data(request, qs):
        search_name = request.GET.get('search_name', None)
        costumer_name = request.GET.getlist('costumer_name', None)
        date_start, date_end, date_range = initial_date(request, 6)
        qs = qs.filter(date__range=[date_start, date_end
                                    ]) if date_start and date_end else qs

        return qs
Beispiel #3
0
 def filters_data(request, qs):
     q = request.GET.get('q', None)
     paid_name = request.GET.getlist('paid_name', None)
     date_start, date_end, date_range = initial_date(request, months=12)
     if q:
         qs = qs.filter(
             Q(customer__first_name__icontains=q)
             | Q(customer__last_name__icontains=q)
             | Q(customer__amka__icontains=q)
             | Q(customer__cellphone__icontains=q)
             | Q(customer__phone__icontains=q)).distinct()
     qs = qs.filter(is_paid=True) if 'have_' in paid_name else qs.filter(
         is_paid=False) if 'not_' in paid_name else qs
     if date_range:
         qs = qs.filter(date__range=[date_start, date_end])
     return qs
Beispiel #4
0
 def filters_data(request, queryset):
     paid_name = request.GET.getlist('paid_name', None)
     search_name = request.GET.get('search_name', None)
     cate_name = request.GET.getlist('cate_name', None)
     bill_name = request.GET.getlist('bill_name', None)
     date_start, date_end, date_range = initial_date(request, 6)
     queryset = queryset.filter(date_expired__range=[date_start, date_end]
                                ) if date_start else queryset
     queryset = queryset.filter(is_paid=True) if 'have_' in paid_name else queryset.filter(is_paid=False) \
         if 'not_' in paid_name else queryset
     queryset = queryset.filter(
         category__id__in=cate_name) if cate_name else queryset
     queryset = queryset.filter(
         category__id__in=bill_name) if bill_name else queryset
     queryset = queryset.filter(
         Q(title__icontains=search_name)
         | Q(category__title__icontains=search_name)).distinct(
         ) if search_name else queryset
     return queryset
Beispiel #5
0
    def filters_data(request, qs):
        search_name = request.GET.get('search_name', None)
        q = request.GET.get('q', None)
        costumer_name = request.GET.getlist('costumer_name', None)

        date_start, date_end, date_range = initial_date(request, 6)
        if date_start and date_end:
            qs = qs.filter(date__range=[date_start, date_end])

        qs = qs.filter(costumer_id__in=costumer_name) if costumer_name else qs
        if search_name:
            qs = qs.filter(Q(title__icontains=search_name) |
                           Q(costumer__title__icontains=search_name)
                           ).distinct()
        if q:
            qs = qs.filter(Q(title__icontains=q) |
                           Q(costumer__title__icontains=q)
                           ).distinct()
        return qs
Beispiel #6
0
 def filter_data(request, qs):
     date_start, date_end, date_range = initial_date(request, 6)
     if date_start and date_end:
         qs = qs.filter(invoice__date__range=[date_start, date_end])
     return qs