from django_filters import rest_framework as filters
from apps.em.models import Equipment
from datetime import datetime, timedelta
from apps.utils.filters import MyJsonListFilter


class EquipFilterSet(filters.FilterSet):
    tags = MyJsonListFilter(label='tags/json/list查询')

    class Meta:
        model = Equipment
        fields = {
            "keeper": ["exact"],
            "type": ["exact"],
            "power_kw": ["gte"],
            "belong_dept": ["exact"],
            "belong_dept__name": ["exact"],
            "mgroup": ["exact"],
            "mgroup__name": ["exact"],
            "name": ["exact", "contains"],
            "cate": ["exact", "in"],
            "cate__code": ['exact', 'in', 'contains'],
            "cate__is_for_safe": ['exact'],
            "cate__is_for_enp": ['exact'],
            "cate__is_car": ['exact'],
            "state_measure": ["exact", "in"],
        }
