from django_filters import rest_framework as filters
from .models import Record, PgoalDept


class RecordFilter(filters.FilterSet):
    date_lt = filters.DateFilter(field_name='up_date',lookup_expr="lt")
    date_gt = filters.DateFilter(field_name='up_date',lookup_expr="gt")
    belong_dept=filters.NumberFilter(field_name='belong_dept')
    content__name = filters.CharFilter(field_name='content__name')
    content__candoself = filters.BooleanFilter(field_name='content__candoself')
    state = filters.CharFilter(field_name='state',lookup_expr='icontains')
    is_self = filters.BooleanFilter(field_name='is_self', lookup_expr='isnull')
    class Meta:
        model = Record
        fields = ['up_date','content__name','belong_dept','state','is_self','task', 'content', 'content__candoself']

class PgoalDeptFilter(filters.FilterSet):
    ['goal_key', 'belong_dept', 'year', 'task2do']
    class Meta:
        model =  PgoalDept
        fields = {
            'goal_key': ['exact', 'in'],
            'belong_dept': ['exact', 'in'],
            'year': ['exact', 'in'],
            'task2do': ['exact', 'in'],
        }