# coding=utf-8
import django_filters

from .models import KnowledgeBase, KnowledgeBaseFeedback

class KnowledgeBaseFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name="name", lookup_expr="icontains")
    subject = django_filters.CharFilter(field_name='chapter__subject_id')
    chapter = django_filters.CharFilter(field_name='chapter_id')

    class Meta:
        model = KnowledgeBase
        fields = "__all__"

class KnowledgeBaseFeedbackFilter(django_filters.FilterSet):
    chapter = django_filters.CharFilter(field_name='main__chapter_id')
    subject = django_filters.CharFilter(field_name='main__chapter__subject_id')
    status = django_filters.CharFilter(field_name='status')
    type = django_filters.CharFilter(field_name='type')
    name = django_filters.CharFilter(field_name='main__name', lookup_expr='icontains')

    class Meta:
        model = KnowledgeBaseFeedback
        fields = '__all__'