from django_filters import rest_framework as filters

from .models import Checklist, Gift


class GiftFilter(filters.FilterSet):
    for_price = filters.NumberFilter(method='filter_for_price')

    class Meta:
        model = Gift
        fields = ('for_price',)

    def filter_for_price(self, queryset, name, value):
        return queryset.filter(min_price__lte=value)


class ChecklistFilter(filters.FilterSet):
    status = filters.MultipleChoiceFilter(choices=Checklist.Status.CHOICES)

    class Meta:
        model = Checklist
        fields = ('status',)
