Esempio n. 1
0
class PlayerFilter(django_filters.FilterSet):
    player_name = django_filters.CharFilter(field_name='player_name',
                                            label='Player Name',
                                            lookup_expr='icontains')

    player_kills = django_filters.RangeFilter(
        field_name='player_kills',
        label='Player Kills',
    )

    player_survive_time = django_filters.RangeFilter(
        field_name='player_survive_time',
        label='Player Survive Time(s)',
    )

    match = django_filters.ModelChoiceFilter(field_name='match',
                                             label='Match Attended',
                                             queryset=Match.objects.all(),
                                             lookup_expr='exact')

    class Meta:
        model = Player
        # form = SearchForm
        # fields [] is required, even if empty.
        fields = []
Esempio n. 2
0
class FirstFilter(django_filters.FilterSet):
    source = django_filters.CharFilter(
        method='filter_by_source', label="Source (Ra,Dec,Radius,Sexigessimal)")
    FIRST = django_filters.CharFilter(lookup_expr='icontains')
    RAJ2000 = django_filters.RangeFilter()
    DEJ2000 = django_filters.RangeFilter()
    Fint = django_filters.NumberFilter(lookup_expr='icontains')
    c1 = django_filters.CharFilter(lookup_expr='icontains')

    class Meta:
        model = FIRST
        fields = [
            'DEJ2000',
        ]

    def filter_by_source(self, qs, name, value):
        if value is not None:
            parms = value.split(',')
            if len(parms) == 4:
                radius = float(parms[2])
                sexi = parms[3]
                try:
                    ra, de = translate_source(parms[0], parms[1], sexi)
                except:
                    return FIRST.objects.none()
                #caculate upper and lower case
                ra_up = ra + radius
                ra_low = ra - radius
                de_up = de + radius
                de_low = de - radius
                qs = qs.filter(RAJ2000__gte=ra_low,
                               RAJ2000__lte=ra_up,
                               DEJ2000__gte=de_low,
                               DEJ2000__lte=de_up).order_by('-ID')
        return qs
Esempio n. 3
0
class LotFilter(django_filters.FilterSet):
    collection = django_filters.Filter(field_name='collection__short_title',
                                       lookup_expr='icontains')
    category = django_filters.Filter(
        field_name='category__bookseller_category', lookup_expr='icontains')
    number_in_collection = django_filters.RangeFilter(
        widget=django_filters.widgets.RangeWidget())
    page_in_collection = django_filters.RangeFilter(
        widget=django_filters.widgets.RangeWidget())
    sales_price = django_filters.Filter(lookup_expr='icontains')
    lot_as_listed_in_collection = django_filters.Filter(
        lookup_expr='icontains')
    number_of_items = django_filters.Filter(
        label='Number of items',
        method='number_of_items_filter',
        widget=django_filters.widgets.RangeWidget())

    class Meta:
        model = Lot
        exclude = ['uuid']

    def number_of_items_filter(self, queryset, name, value):
        if any(value):
            queryset = queryset.annotate(num_items=Count('item'))
            if value[0]:
                queryset = queryset.filter(num_items__gte=value[0])
            if value[1]:
                queryset = queryset.filter(num_items__lte=value[1])
        return queryset
Esempio n. 4
0
class CarFilter(django_filters.FilterSet):
    initial_values = Car.objects.select_related('cars_ads').prefetch_related(
        'cars_ads__price', 'year').aggregate(year_min=Min('year'),
                                             year_max=Max('year'),
                                             price_min=Min('cars_ads__price'),
                                             price_max=Max('cars_ads__price'))
    year = django_filters.RangeFilter(
        lookup_expr='exact',
        help_text=str(initial_values['year_min']) + ' - ' +
        str(initial_values['year_max']))
    drive = django_filters.MultipleChoiceFilter(choices=Car.CAR_DRIVE_CHOICES,
                                                label="Drive unit",
                                                widget=CheckboxSelectMultiple)
    cars_ads__price = django_filters.RangeFilter(
        lookup_expr='exact',
        help_text=str(initial_values['price_min']) + ' - ' +
        str(initial_values['price_max']))
    volume = django_filters.NumberFilter(field_name='volume', lookup_expr='gt')
    power = django_filters.NumberFilter(field_name='power', lookup_expr='gt')

    class Meta:
        model = Car
        fields = [
            'producer', 'year', 'type', 'volume', 'power', 'drive',
            'cars_ads__price'
        ]
Esempio n. 5
0
class MusicalExperienceFilter(filters.FilterSet):
    experience = filters.ModelMultipleChoiceFilter(
        queryset=MusicalSkill.objects.all(),
        widget=Select2MultipleWidget(attrs={}),
        label="Skilled In Any Of",
        field_name="experience")

    m_proficiency = filters.MultipleChoiceFilter(
        field_name="proficiency",
        choices=PROFICIENCY_M_CHOICES,
        widget=Select2MultipleWidget(),
        lookup_expr='icontains',
        label="Proficiency Level")
    m_age_learning_started = filters.RangeFilter(
        field_name="age_learning_started",
        label="Age Learning Started Range",
        widget=RangeWidget(attrs={
            'type': 'number',
            'class': 'form-control mb-2'
        }))
    m_age_learning_ended = filters.RangeFilter(
        field_name="age_learning_ended",
        label="Age Learning Ended Range",
        widget=RangeWidget(attrs={
            'type': 'number',
            'class': 'form-control mb-2'
        }))

    class Meta:
        model = MusicalExperience
        fields = [
            'experience', 'proficiency', 'age_learning_started',
            'age_learning_ended'
        ]
Esempio n. 6
0
class BookFilterSet(django_filters.FilterSet):
    title = django_filters.CharFilter(
        lookup_expr='icontains',
        widget=forms.TextInput(attrs={'class': 'uk-input'}))
    description = django_filters.CharFilter(
        lookup_expr='icontains',
        widget=forms.TextInput(attrs={'class': 'uk-input'}))
    year = django_filters.RangeFilter(widget=widgets.RangeWidget(
        attrs={'class': 'uk-input'}))
    page_count = django_filters.RangeFilter(widget=widgets.RangeWidget(
        attrs={'class': 'uk-input'}))
    tags = django_filters.ModelMultipleChoiceFilter(
        queryset=Tag.objects.all(),
        widget=forms.SelectMultiple(attrs={'class': 'uk-select'}))
    publishers = django_filters.ModelMultipleChoiceFilter(
        queryset=Publisher.objects.all(),
        widget=forms.SelectMultiple(attrs={'class': 'uk-select'}))
    authors = django_filters.ModelMultipleChoiceFilter(
        queryset=Author.objects.all(),
        widget=forms.SelectMultiple(attrs={'class': 'uk-select'}))

    class Meta:
        model = Book
        fields = (
            'title',
            'publishers',
            'authors',
            'description',
            'year',
            'page_count',
            'tags',
        )
Esempio n. 7
0
class WindowFilter(filters.FilterSet):
    seller = filters.ModelChoiceFilter(
        queryset=get_sellers,
        widget=BootstrapSelect,
    )
    width = filters.RangeFilter(widget=BootstrapRange(
        attrs_0={"placeholder": Window.objects.get_min_width},
        attrs_1={"placeholder": Window.objects.get_max_width},
    ), )
    height = filters.RangeFilter(widget=BootstrapRange(
        attrs_0={"placeholder": Window.objects.get_min_height},
        attrs_1={"placeholder": Window.objects.get_max_height},
    ), )
    type = filters.ChoiceFilter(
        'type',
        choices=Window.Types.choices,
        widget=BootstrapSelect,
    )
    color = filters.MultipleChoiceFilter(
        'color',
        choices=Window.Colors.choices,
        widget=BootstrapMultipleCheckbox,
    )

    class Meta:
        model = Window
        fields = [
            'width',
            'height',
            'type',
            'color',
            'seller',
        ]
class RidingFilter(BaseSportFilter):

    hills = django_filters.RangeFilter(
        field_name='hill_avg',
        widget=RangeWidget(
            attrs={
                'class': "form-control form-control-sm col",
                'placeholder': "Speed in kph",
                'style': 'margin-left: 10px; margin-right: 10px;'
            }))
    flats = django_filters.RangeFilter(
        field_name='flat_avg',
        widget=RangeWidget(
            attrs={
                'class': "form-control form-control-sm col",
                'placeholder': "Speed in kph",
                'style': 'margin-left: 10px; margin-right: 10px;'
            }))
    weekly_volume = django_filters.NumberFilter(
        field_name='weekly_volume',
        lookup_expr='gt',
        widget=TextInput(
            attrs={
                'class': "form-control form-control col",
                'placeholder': "Minimum Weekly Volume (in km)"
            }))

    class Meta:
        model = RidingProfile
        fields = []
Esempio n. 9
0
class DebtorDataFilter(django_filters.FilterSet):
    OWNERSHIP_CHOICES = (
        ('', 'All'),
        ('Public', 'Public'),
        ('Private', 'Private'),
    )
    JURISDICTION_CHOICES = create_jurisdiction_choices()

    ownership = django_filters.CharFilter(
        field_name='ownership',
        label='Ownership',
        widget=forms.Select(choices=OWNERSHIP_CHOICES))
    pay_terms = django_filters.RangeFilter(label='Pay Terms Range (min-max)')
    jurisdiction = django_filters.MultipleChoiceFilter(
        field_name='jurisdiction',
        choices=JURISDICTION_CHOICES,
        widget=forms.CheckboxSelectMultiple)
    oarex_rating = django_filters.RangeFilter(
        label='Oarex rating range (min-max)')
    company = django_filters.CharFilter(field_name='company',
                                        lookup_expr='icontains',
                                        label='Company Search')

    class Meta:
        model = DebtorData
        fields = [
            'company', 'oarex_rating', 'pay_terms', 'jurisdiction', 'ownership'
        ]
Esempio n. 10
0
class DisplayVehiclesDatabaseFilter(django_filters.FilterSet):
    pricenew = django_filters.RangeFilter()
    make = django_filters.CharFilter(lookup_expr='icontains')
    model = django_filters.CharFilter(lookup_expr='icontains')
    series = django_filters.CharFilter(lookup_expr='icontains')
    year = django_filters.RangeFilter()
    enginesize = django_filters.AllValuesMultipleFilter()
    fuelsystem = django_filters.AllValuesMultipleFilter()
    tankcapacity = django_filters.AllValuesMultipleFilter()
    power = django_filters.AllValuesMultipleFilter()
    seatcapacity = django_filters.AllValuesMultipleFilter()
    standardtransmission = django_filters.AllValuesMultipleFilter()
    bodytype = django_filters.AllValuesMultipleFilter()
    drive = django_filters.AllValuesMultipleFilter()
    wheelbase = django_filters.AllValuesMultipleFilter()

    class Meta:
        model = Vehicles
        fields = [
            'make',
            'model',
            'series',
            'year',
            'pricenew',
            'enginesize',
            'fuelsystem',
            'tankcapacity',
            'power',
            'seatcapacity',
            'standardtransmission',
            'bodytype',
            'drive',
            'wheelbase',
        ]
Esempio n. 11
0
class WindSpeedFilterSet(django_filters.FilterSet):
    timestamp = timestamp_dt_filter
    value = django_filters.RangeFilter()
    temperature = django_filters.RangeFilter()

    class Meta:
        model = WindSpeed
        fields = ['timestamp', 'value', 'temperature']
Esempio n. 12
0
class FlatFilter(django_filters.FilterSet):
    fId = django_filters.CharFilter(lookup_expr='icontains')
    layers = django_filters.RangeFilter()
    roomNum = django_filters.RangeFilter()

    class Meta:
        model = Flat
        fields = ['fId', 'layers', 'roomNum']
Esempio n. 13
0
class RoomFilter(django_filters.FilterSet):
    num_bathrooms = django_filters.RangeFilter()
    num_bedrooms = django_filters.RangeFilter()
    num_floors = django_filters.RangeFilter()
    num_recepts = django_filters.RangeFilter()

    class Meta:
        model = Property
        fields = ('num_bathrooms', 'num_bedrooms', 'num_floors', 'num_recepts')
Esempio n. 14
0
class ProjectsFilter(django_filters.FilterSet):
    project_name = django_filters.CharFilter(lookup_expr='icontains')
    time_for_project_hours = django_filters.RangeFilter(
        label="Range of time for project")
    profit = django_filters.RangeFilter(label="Range of profit")

    class Meta:
        model = Projects
        fields = ['project_name', 'time_for_project_hours', 'profit']
Esempio n. 15
0
class DormitoryFilter(django_filters.FilterSet):
    dId = django_filters.CharFilter(lookup_expr='icontains')
    telephone = django_filters.CharFilter(lookup_expr='icontains')
    peopleNum = django_filters.RangeFilter()
    accommodationCharge = django_filters.RangeFilter()

    class Meta:
        model = Dormitory
        fields = "__all__"
Esempio n. 16
0
class StationLocationFilterSet(django_filters.FilterSet):
    timestamp = timestamp_dt_filter
    lat = django_filters.RangeFilter()
    lon = django_filters.RangeFilter()
    is_actual = django_filters.BooleanFilter()

    class Meta:
        model = StationLocation
        fields = ['timestamp', 'lat', 'lon', 'is_actual']
Esempio n. 17
0
class AccelerometerXyzFilterSet(django_filters.FilterSet):
    timestamp = timestamp_dt_filter
    x = django_filters.RangeFilter()
    y = django_filters.RangeFilter()
    z = django_filters.RangeFilter()

    class Meta:
        model = AccelerometerXyz
        fields = ['timestamp', 'x', 'y', 'z']
Esempio n. 18
0
class LatLngFilter(django_filters.FilterSet):

    lat = django_filters.RangeFilter()
    lng = django_filters.RangeFilter()
    facilityId = django_filters.CharFilter()

    class Meta:
        model = Places
        fields = ['lat', 'lng', 'facilityId']
Esempio n. 19
0
class CompassXyzFilterSet(django_filters.FilterSet):
    timestamp = timestamp_dt_filter
    x = django_filters.RangeFilter()
    y = django_filters.RangeFilter()
    z = django_filters.RangeFilter()

    class Meta:
        model = CompassXyz
        fields = ['timestamp', 'x', 'y', 'z']
Esempio n. 20
0
class AnnotationFilterSet(django_filters.FilterSet):
    vector_x = django_filters.RangeFilter(method='get_vector_x_filter',
                                          field_name='vector',
                                          label="Vector-X-Range")
    vector_y = django_filters.RangeFilter(method='get_vector_y_filter',
                                          field_name='vector',
                                          label="Vector-Y-Range")
    meta_data__isnull = django_filters.BooleanFilter(
        method='get_meta_data_isnull_filter', field_name='meta_data')
    vector__isnull = django_filters.BooleanFilter(
        method='get_vector_isnull_filter', field_name='vector')
    vector_type = django_filters.NumberFilter(method='get_vector_type',
                                              field_name='vector')

    class Meta:
        model = models.Annotation
        fields = {
            'id': ['exact'],
            'time': ['exact', 'lte', 'gte', 'range'],
            'last_edit_time': ['exact', 'lte', 'gte', 'range'],
            'unique_identifier': ['exact', 'contains'],
            'description': ['exact', 'contains'],
            'deleted': ['exact'],
            'image': ['exact'],  #, 'range'
            'user': ['exact'],
            'annotation_type': ['exact'],  #, 'range'
            'verified_by': ['exact', 'range'],  #, 'range'
            'annotationversion': ['exact'],
        }

    def get_vector_type(self, queryset, field_name, value):
        return queryset.filter(annotation_type__vector_type=value)

    def get_vector_isnull_filter(self, queryset, field_name, value):
        return queryset.filter(vector__isnull=value)

    def get_meta_data_isnull_filter(self, queryset, field_name, value):
        return queryset.filter(meta_data__isnull=value)

    def get_vector_x_filter(self, queryset, field_name, value):
        if value:
            queryset = queryset.exclude(vector__isnull=True)
            if value.start is not None:
                queryset.filter(vector__x1__gte=int(value.start))
            if value.stop is not None:
                queryset = queryset.filter(vector__x1__lt=int(value.stop))
        return queryset

    def get_vector_y_filter(self, queryset, field_name, value):
        if value:
            queryset = queryset.exclude(vector__isnull=True)
            if value.start is not None:
                queryset.filter(vector__y__gte=int(value.start))
            if value.stop is not None:
                queryset = queryset.filter(vector__y1__lt=int(value.stop))
        return queryset
Esempio n. 21
0
class OrderFilter(django_filters.FilterSet):
    """As documentation explains"""

    id = django_filters.CharFilter(
        label=_("Order Id"),
        required=False,
        field_name="order_id",
        lookup_expr="icontains",
    )
    date_after = django_filters.DateFilter(
        label=_("Order After"),
        required=False,
        field_name="order_purchase_date",
        widget=DateInput(attrs={"type": "date"}),
        method="filter_date_after",
    )
    date_before = django_filters.DateFilter(
        label=_("Order Before"),
        required=False,
        field_name="order_purchase_date",
        widget=DateInput(attrs={"type": "date"}),
        method="filter_date_before",
    )
    amount = django_filters.RangeFilter(label=_("Order Amount"),
                                        required=False,
                                        field_name="order_amount")
    items = django_filters.RangeFilter(label=_("Order Items"),
                                       required=False,
                                       field_name="order_items")
    marketplace = django_filters.CharFilter(
        label=_("Marketplace"),
        required=False,
        field_name="marketplace",
        lookup_expr="icontains",
    )

    class Meta:
        model = Order
        fields = [
            "id", "date_after", "date_before", "amount", "items", "marketplace"
        ]

    def filter_date_after(self, queryset, _name, value):  # pylint: disable=R0201
        """Filter of orders after a date"""
        value = datetime.datetime.combine(value,
                                          datetime.time.min,
                                          tzinfo=pytz.timezone("utc"))
        return queryset.filter(order_purchase_date__gte=value)

    def filter_date_before(self, queryset, _name, value):  # pylint: disable=R0201
        """Filter of orders before a date"""
        value = datetime.datetime.combine(value,
                                          datetime.time.max,
                                          tzinfo=pytz.timezone("utc"))
        return queryset.filter(order_purchase_date__lte=value)
Esempio n. 22
0
class Product_Filter(FilterSet):
    name = django_filters.CharFilter(field_name='name',lookup_expr='icontains')
    netprice = django_filters.RangeFilter(lookup_expr='lte',label='Price')
    discount = django_filters.RangeFilter(lookup_expr='lte')
    brand__name = django_filters.ModelChoiceFilter(queryset=Brand.objects.all())
    catid__catname = django_filters.ModelChoiceFilter(queryset=Category.objects.all())
    dod = django_filters.BooleanFilter(field_name='dod',widget=BooleanWidget())
    class Meta:
            model = Product
            fields = ['name', 'netprice','discount']
            exclude = ['image']
Esempio n. 23
0
class OfferFilter(django_filters.FilterSet):
    price = django_filters.RangeFilter()
    rooms_no = django_filters.RangeFilter()
    area = django_filters.RangeFilter()

    class Meta:
        model = Offers
        fields = [
            'object', 'province', 'district', 'location', 'rent', 'rooms_no',
            'price', 'area'
        ]
Esempio n. 24
0
class TableRamFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')
    speed_read = django_filters.RangeFilter()
    speed_write = django_filters.RangeFilter()
    latency = django_filters.RangeFilter()
    in_stock = django_filters.BooleanFilter()
    price = django_filters.RangeFilter()

    class Meta:
        model = models.ScrapperBenchRam
        fields = ['name', 'speed_read', 'speed_write', 'latency', 'in_stock', 'price']
Esempio n. 25
0
class BenthicPITFilterSet(BaseAPIFilterSet):
    interval_size = django_filters.RangeFilter(field_name="interval_size")
    interval_start = django_filters.RangeFilter(field_name="interval_start")

    class Meta:
        model = BenthicPIT
        fields = [
            "transect",
            "transect__sample_event",
            "interval_size",
            "interval_start",
        ]
Esempio n. 26
0
File: views.py Progetto: IFXGlam/IFX
class MovieFilter(django_filters.FilterSet):
    title = django_filters.CharFilter(method='title_filter', label=_("title"))
    year = django_filters.RangeFilter()
    duration = django_filters.RangeFilter()
    tags__tag = django_filters.ChoiceFilter(choices=get_tags, label=_("Genre"))
    summary = django_filters.CharFilter(method='summary_filter',
                                        label=_("summary"))

    ordering = django_filters.OrderingFilter(label=_("ordering"),
                                             fields=(
                                                 ('title_he', 'title_he'),
                                                 ('title_en', 'title_en'),
                                                 ('year', 'year'),
                                                 ('duration', 'duration'),
                                             ),
                                             field_labels={
                                                 'title_he':
                                                 _('Hebrew Title (A -> Z)'),
                                                 'title_en':
                                                 _('English Title (A -> Z)'),
                                                 'year':
                                                 _('Year (Old -> New)'),
                                                 'duration':
                                                 _('Duration (Short -> long)'),
                                                 '-title_he':
                                                 _('Hebrew title (Z -> A)'),
                                                 '-title_en':
                                                 _('English title (Z -> A)'),
                                                 '-year':
                                                 _('Year (New -> Old)'),
                                                 '-duration':
                                                 _('Duration (Long -> Short)'),
                                             })

    class Meta:
        model = Movie
        fields = (
            'title',
            'year',
            'duration',
            'tags__tag',
        )

    def title_filter(self, queryset, name, value):
        q = Q(title_en__icontains=value) | Q(title_he__icontains=value)
        return queryset.filter(q)

    def summary_filter(self, queryset, name, value):
        q = Q(summary_en__icontains=value) | Q(summary_he__icontains=value)
        return queryset.filter(q)
Esempio n. 27
0
class PackageFilter(django_filters.FilterSet):

    price_per_persion = django_filters.RangeFilter(
        field_name='ActualPricePerPerson')
    package_days = django_filters.RangeFilter(field_name='PackageDays')

    # hotel__stars = django_filters.NumberFilter(field_name=hotel_package)
    class Meta:
        model = Package
        fields = {
            'category', 'package_days', 'price_per_persion',
            'Destination__DestinationType', 'activity', 'inclusion',
            'Destination'
        }
Esempio n. 28
0
class MovieFilter(django_filters.FilterSet):
    title = django_filters.CharFilter(field_name='title',
                                      label='Movie Title Name',
                                      lookup_expr='icontains')

    movie_language = django_filters.ModelChoiceFilter(
        field_name='language',
        label='language',
        queryset=MovieLanguage.objects.all().order_by('language_name'),
        lookup_expr='exact')

    score = django_filters.RangeFilter(field_name="imdb_score", label='score')
    genre = django_filters.ModelMultipleChoiceFilter(
        field_name="genre",
        queryset=Genre.objects.all().order_by("genre_name"),
    )

    keyword = django_filters.CharFilter(field_name="keyword__keyword_name",
                                        label='keyword',
                                        lookup_expr='icontains')
    director = django_filters.CharFilter(field_name='director__director_name',
                                         label='Director',
                                         lookup_expr='icontains')

    actor = django_filters.ModelMultipleChoiceFilter(
        field_name="actor",
        queryset=Actor.objects.all().order_by("actor_name"),
    )

    class Meta:
        model = Movie
        fields = []
Esempio n. 29
0
class ObsBeltFishFilterSet(BaseAPIFilterSet):
    size = django_filters.RangeFilter(field_name="size")
    count = django_filters.RangeFilter(field_name="count")

    class Meta:
        model = ObsBeltFish
        fields = [
            "beltfish",
            "beltfish__transect",
            "beltfish__transect__sample_event",
            "fish_attribute",
            "size_bin",
            "include",
            "size",
            "count",
        ]
class ProductFilter(django_filters.FilterSet):

    price = django_filters.RangeFilter(field_name='min_price')  # single option
    material = CustomFilterList(lookup_expr="in")  # multiple
    fit = CustomFilterList(lookup_expr="in")  # multiple
    offer = django_filters.NumberFilter(field_name='offer_of_min',
                                        lookup_expr='gte')  # single option
    usersection = CustomFilterList(field_name='usersection',
                                   lookup_expr="in")  # multiple
    category = CustomFilterList(field_name='category',
                                lookup_expr="in")  # multiple
    subcategory = CustomFilterList(field_name='subcategory',
                                   lookup_expr="in")  # multiple
    subsubcategory = CustomFilterList(field_name='subsubcategory',
                                      lookup_expr="in")  # multiple
    colour = CustomColourFilter(field_name='available_colours__colour',
                                lookup_expr="in")  # multiple
    size = CustomSizeFilter(field_name="available_colours__size_and_qty__size",
                            lookup_expr="in")  # multiple

    class Meta:
        model = Product
        fields = {
            'category', 'subcategory', 'subsubcategory', 'usersection',
            'price', 'material', 'fit', 'offer', 'colour', 'size'
        }