import django_filters
from .models import *

class ConfigFilter(django_filters.FilterSet):
    id = django_filters.CharFilter(field_name='id')

    class Meta:
        model = Config
        fields = '__all__'

class SchoolFilter(django_filters.FilterSet):
    agent_name = django_filters.CharFilter(field_name='agent__name', lookup_expr='icontains')
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')

    class Meta:
        model = School
        fields = '__all__'


class GradeFilter(django_filters.FilterSet):
    school_name = django_filters.CharFilter(field_name='school__name', lookup_expr='icontains')
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')

    class Meta:
        model = Grade
        fields = '__all__'


class StudentFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')
    school_name = django_filters.CharFilter(field_name='school__name', lookup_expr='icontains')
    grade_name = django_filters.CharFilter(field_name='classes__grade__name', lookup_expr='icontains')
    classes_name = django_filters.CharFilter(field_name='classes__name', lookup_expr='icontains')
    create_user_tel = django_filters.CharFilter(field_name='create_user__username', lookup_expr='icontains')

    class Meta:
        model = Student
        fields = '__all__'

class CommodityLevelFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name='name', lookup_expr='icontains')
    category_name = django_filters.CharFilter(field_name='category__name', lookup_expr='icontains')

    class Meta:
        model = CommodityLevel
        fields = '__all__'
