#coding=utf-8
import django_filters
from apps.base import clean_datetime_range
from .models import *

class EmployeeFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name='name',lookup_expr='icontains')
    username = django_filters.CharFilter(field_name='username', lookup_expr='icontains')
    enabled = django_filters.CharFilter(field_name='enabled')

    class Meta:
        model = User
        fields = (
            'name', 'username', 'enabled'
        )

    def __init__(self, data=None, *args, **kwargs):
        data = clean_datetime_range(data, 'create_time')
        super(EmployeeFilter, self).__init__(data, *args, **kwargs)