<commit_before>from __future__ import unicode_literals

from django import forms

import django_filters

from ..filters import BaseFilterSet
from .models import Listing


class LowStockListingFilter(django_filters.Filter):
    field_class = forms.BooleanField

    def filter(self, qs, value):
        if value:
            qs = qs.filter(pk__in=Listing.objects.low_stock_ids())

        return qs


class LowPriceListingFilter(django_filters.Filter):
    field_class = forms.BooleanField

    def filter(self, qs, value):
        if value:
            qs = qs.filter(pk__in=Listing.objects.low_cost_ids())
        return qs


class ListingFilter(BaseFilterSet):
    title = django_filters.CharFilter(lookup_type="icontains")
    low_stock = LowStockListingFilter()
    low_price = LowPriceListingFilter()

    class Meta:
        model = Listing
        fields = ["title", "publishings__store", "publishings__available_units"]<commit_msg>available units lookup changed to lower than equal<commit_after>from __future__ import unicode_literals

from django import forms

import django_filters

from ..filters import BaseFilterSet
from .models import Listing


class LowStockListingFilter(django_filters.Filter):
    field_class = forms.BooleanField

    def filter(self, qs, value):
        if value:
            qs = qs.filter(pk__in=Listing.objects.low_stock_ids())

        return qs


class LowPriceListingFilter(django_filters.Filter):
    field_class = forms.BooleanField

    def filter(self, qs, value):
        if value:
            qs = qs.filter(pk__in=Listing.objects.low_cost_ids())
        return qs


class ListingFilter(BaseFilterSet):
    title = django_filters.CharFilter(lookup_type="icontains")
    available_units = django_filters.NumberFilter(name="publishings__available_units",
                                                  lookup_type="lte")
    low_stock = LowStockListingFilter()
    low_price = LowPriceListingFilter()

    class Meta:
        model = Listing
        fields = ["title", "publishings__store", "available_units"]
{'fraction_non_alphanumeric': 0.08017492711370262, 'fraction_numerical': 0.0, 'mean_word_length': 3.390191897654584, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6406844', 'n_tokens_mistral': 604, 'n_tokens_neox': 580, 'n_words': 133}