# coding=utf-8

import django_filters
from .models import InspectionOrder


class InspectionOrderFilter(django_filters.FilterSet):
    status = django_filters.CharFilter(method='query_status')
    no = django_filters.CharFilter(field_name='no', lookup_expr='icontains')

    class Meta:
        model = InspectionOrder
        fields = '__all__'

    def query_status(self, queryset, *args):
        queryset = queryset.filter(status__in=args[1].split(','))
        print(queryset)
        return queryset