# coding=utf-8
import django_filters

from django.contrib.auth import get_user_model
from .models import Department

User = get_user_model()

class UserFilter(django_filters.FilterSet):
    username = django_filters.CharFilter(field_name='username', lookup_expr='icontains')
    is_active = django_filters.CharFilter(field_name='is_active')
    department = django_filters.CharFilter(field_name='department_id')

    class Meta:
        model = User
        fields = ['username', 'is_active', 'type', ]

class DepartmentFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')

    class Meta:
        model = Department
        fields = ['name',]