# coding=utf-8
import django_filters

from .models import Exam, ExamLog

class ExamFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(field_name="name", lookup_expr="icontains")
    subject = django_filters.CharFilter(field_name='subject_id')
    type = django_filters.CharFilter(field_name='type')

    class Meta:
        model = Exam
        fields = "__all__"

class FormalExamLogFilter(django_filters.FilterSet):
    exam_name = django_filters.CharFilter(field_name="exam__name", lookup_expr="icontains")
    user_name = django_filters.CharFilter(field_name="user__name", lookup_expr="icontains")
    exam_subject = django_filters.CharFilter(field_name='exam__subject_id')
    exam_type = django_filters.CharFilter(field_name='exam__type')

    class Meta:
        model = ExamLog
        fields = "__all__"
