# coding=utf-8
import django_filters

from .models import Subject, Chapter


class SubjectFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name="name", lookup_expr="icontains")

    class Meta:
        model = Subject
        fields = "__all__"


class ChapterFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name="name", lookup_expr="icontains")
    subject_name = django_filters.CharFilter(field_name="subject__name", lookup_expr="icontains")

    class Meta:
        model = Chapter
        fields = "__all__"
