Пример #1
0
class UsageEventFilter(FilterSet):
    start_gte = IsoDateTimeFilter('start', lookup_expr='gte')
    start_lt = IsoDateTimeFilter('start', lookup_expr='lt')

    class Meta:
        model = UsageEvent
        fields = []
Пример #2
0
class AreaAccessRecordFilter(FilterSet):
    start_gte = IsoDateTimeFilter('start', lookup_expr='gte')
    start_lt = IsoDateTimeFilter('start', lookup_expr='lt')

    class Meta:
        model = AreaAccessRecord
        fields = []
Пример #3
0
class ReservationFilter(FilterSet):
    start_gte = IsoDateTimeFilter('start', lookup_expr='gte')
    start_lt = IsoDateTimeFilter('start', lookup_expr='lt')
    missed = BooleanFilter('missed', widget=BooleanWidget())

    class Meta:
        model = Reservation
        fields = []
Пример #4
0
class RetreatFilter(FilterSet):
    finish_after = IsoDateTimeFilter(field_name='max_end_date',
                                     lookup_expr='gte')
    start_after = IsoDateTimeFilter(field_name='min_start_date',
                                    lookup_expr='gte')

    type__id = NumberFilter(field_name='type', lookup_expr='exact')

    class Meta:
        model = Retreat
        fields = '__all__'
Пример #5
0
class _ModifiedOnFilter(FilterSet):
    """Filter set for the modified-since view."""

    modified_on__gte = IsoDateTimeFilter(field_name='modified_on',
                                         lookup_expr='gte')
    modified_on__lte = IsoDateTimeFilter(field_name='modified_on',
                                         lookup_expr='lte')

    class Meta:
        model = InvestmentProject
        fields = ()
Пример #6
0
class WarcFilter(FilterSet):
    # Allows queries like /api/v1/warcs/?collection=39c00280274a4db0b1cb5bfa4d527a1e
    collection = CharFilter(name="harvest__historical_collection__collection_id")
    seed = ListFilter(name="harvest__historical_seeds__seed_id", distinct=True)
    harvest_date_start = IsoDateTimeFilter(name="harvest__date_started", lookup_expr='gte')
    harvest_date_end = IsoDateTimeFilter(name="harvest__date_started", lookup_expr='lte')
    created_date_start = IsoDateTimeFilter(name="date_created", lookup_expr='gte')
    created_date_end = IsoDateTimeFilter(name="date_created", lookup_expr='lte')

    class Meta:
        model = Warc
        fields = ['collection']
Пример #7
0
class tblLogsFilter(django_filters.FilterSet):
    startdate = IsoDateTimeFilter(field_name="eventdatetime",  lookup_expr='gte')
    enddate = IsoDateTimeFilter(field_name="eventdatetime", lookup_expr='lte') 
    eventname = CharFilter(field_name="eventname", lookup_expr="icontains")
    description = CharFilter(field_name="description", lookup_expr="icontains")
    filepathname = CharFilter(field_name="filepathname", lookup_expr="icontains")
    transfduration = CharFilter(field_name="transfduration", lookup_expr="icontains")
    tohost = CharFilter(field_name="tohost", lookup_expr="icontains")
    fromhost = CharFilter(field_name="fromhost", lookup_expr="icontains")

    class Meta:
        model=tblLogs
        fields = '__all__'
Пример #8
0
class HistoryFilter(_BaseFilter):
    start_time__gt = IsoDateTimeFilter(name="start_time",
                                       lookup_expr=('gt'))
    stop_time__gt = IsoDateTimeFilter(name="stop_time",
                                      lookup_expr=('gt'))
    start_time__lt = IsoDateTimeFilter(name="start_time",
                                       lookup_expr=('lt'))
    stop_time__lt = IsoDateTimeFilter(name="stop_time",
                                      lookup_expr=('lt'))
    start_time__gte = IsoDateTimeFilter(name="start_time",
                                        lookup_expr=('gte'))
    stop_time__gte = IsoDateTimeFilter(name="stop_time",
                                       lookup_expr=('gte'))
    start_time__lte = IsoDateTimeFilter(name="start_time",
                                        lookup_expr=('lte'))
    stop_time__lte = IsoDateTimeFilter(name="stop_time",
                                       lookup_expr=('lte'))

    class Meta:
        model = models.History
        fields = ('id',
                  'mode',
                  'kind',
                  'project',
                  'status',
                  'inventory',
                  'start_time',
                  'stop_time',
                  'initiator',
                  'initiator_type')
Пример #9
0
class AllFiltersFilterSet(FilterSet):
    number_AllValuesFilter = AllValuesFilter(field_name='number', lookup_expr='exact')
    number_AllValuesMultipleFilter_OR = AllValuesMultipleFilter(field_name='number', lookup_expr='exact', conjoined=False)  # OR
    number_AllValuesMultipleFilter_AND = AllValuesMultipleFilter(field_name='number', lookup_expr='exact', conjoined=True)  # AND
    number_BaseCSVFilterNumber = BaseCSVFilterNumber(field_name='number', lookup_expr='in')
    number_BaseInFilterNumber = BaseInFilterNumber(field_name='number', lookup_expr='in')
    number_BaseRangeFilterNumber = BaseRangeFilterNumber(field_name='number', lookup_expr='range')
    is_true_BooleanFilter = BooleanFilter(field_name='is_true', lookup_expr='exact')
    text_CharFilter = CharFilter(field_name='text', lookup_expr='exact')
    number_ChoiceFilter = ChoiceFilter(field_name='number', lookup_expr='exact', choices=NUMBER_CHOICES)
    date_DateFilter = DateFilter(field_name='date', lookup_expr='exact')
    date_DateFromToRangeFilter = DateFromToRangeFilter(field_name='date', lookup_expr='range')
    date_DateRangeFilter = DateRangeFilter(field_name='date', lookup_expr='exact')
    date_time_DateTimeFilter = DateTimeFilter(field_name='date_time', lookup_expr='exact')
    date_time_DateTimeFromToRangeFilter = DateTimeFromToRangeFilter(field_name='date_time', lookup_expr='range')
    duration_DurationFilter = DurationFilter(field_name='duration', lookup_expr='exact')
    iso_date_time_IsoDateTimeFilter = IsoDateTimeFilter(field_name='iso_date_time', lookup_expr='lt')
    iso_date_time_IsoDateTimeFromToRangeFilter = IsoDateTimeFromToRangeFilter(field_name='iso_date_time', lookup_expr='range')
    number_MultipleChoiceFilter_OR = MultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=False, choices=NUMBER_CHOICES)
    number_MultipleChoiceFilter_AND = MultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=True, choices=NUMBER_CHOICES)
    number_NumberFilter = NumberFilter(field_name='number', lookup_expr='exact')
    number_OrderingFilter = OrderingFilter(fields=('number', 'number'))
    number_RangeFilter = RangeFilter(field_name='number', lookup_expr='range')
    time_TimeFilter = TimeFilter(field_name='time', lookup_expr='exact')
    time_TimeRangeFilter = TimeRangeFilter(field_name='time', lookup_expr='range')
    number_TypedChoiceFilter = TypedChoiceFilter(field_name='number', lookup_expr='exact', choices=NUMBER_CHOICES)
    text_TypedMultipleChoiceFilter_OR = TypedMultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=False, choices=NUMBER_CHOICES)
    text_TypedMultipleChoiceFilter_AND = TypedMultipleChoiceFilter(field_name='number', lookup_expr='exact', conjoined=True, choices=NUMBER_CHOICES)
    uuid_UUIDFilter = UUIDFilter(field_name='uuid', lookup_expr='exact')
    number_LookupChoiceFilter = LookupChoiceFilter(field_name='number')

    class Meta:
        model = BenchmarkModel
        exclude = ['number', 'text', 'is_true', 'date', 'date_time', 'duration']
Пример #10
0
class ArticleFilter(django_filters.FilterSet):
    last_edit = IsoDateTimeFilter(field_name="last_edit", lookup_expr='gte')
    subject = CharFilter(field_name="subject", lookup_expr="exact")

    class Meta:
        model = DraftArticles
        fields = ['last_edit', 'subject']
    class DateTimeFilterSet(FilterSet):
        date_time = IsoDateTimeFilter(field_name='date_time',
                                      lookup_expr=lookup_xpr)

        class Meta:
            model = IsoDateTimeFilterModel
            fields = ['date_time']
Пример #12
0
class TableFilter(FilterSet):
    free_at = IsoDateTimeFilter(field_name='free_at', method='filter_free_at')

    def filter_free_at(self, queryset, name, value):
        before_booking_hour_q = Q(tablebooking__destination_time__gte=value - timedelta(hours=1)) & \
                                Q(tablebooking__destination_time__lte=value + timedelta(hours=1))
        return queryset.exclude(before_booking_hour_q)
    class PropertyIsoDateTimeFilterSet(PropertyFilterSet):
        date_time = IsoDateTimeFilter(field_name='date_time',
                                      lookup_expr=lookup_xpr)
        prop_date_time = PropertyIsoDateTimeFilter(field_name='prop_date_time',
                                                   lookup_expr=lookup_xpr)

        class Meta:
            model = IsoDateTimeFilterModel
            fields = ['prop_date_time']
Пример #14
0
class HistoryFilter(_BaseFilter):
    status = CharFilter(help_text='Status of execution.')
    mode = CharFilter(help_text='Module or playbook name.')
    kind = CharFilter(help_text='Kind of execution.')
    older = IsoDateTimeFilter(field_name="start_time",
                              lookup_expr=('lt'),
                              help_text='Older then this time')
    newer = IsoDateTimeFilter(field_name="start_time",
                              lookup_expr=('gt'),
                              help_text='Newer then this time')

    class Meta:
        model = models.History
        fields = (
            'id',
            'mode',
            'kind',
            'status',
        )
Пример #15
0
class WarcFilter(FilterSet):
    # Allows queries like /api/v1/warcs/?collection=39c00280274a4db0b1cb5bfa4d527a1e
    collection = CharFilter(
        name="harvest__historical_collection__collection_id")
    seed = ListFilter(name="harvest__historical_seeds__seed_id", distinct=True)
    harvest_date_start = IsoDateTimeFilter(name="harvest__date_started",
                                           lookup_type='gte')
    harvest_date_end = IsoDateTimeFilter(name="harvest__date_started",
                                         lookup_type='lte')
    exclude_web = MethodFilter(action="web_filter")

    class Meta:
        model = Warc
        fields = ['collection']

    @staticmethod
    def web_filter(queryset, value):
        if value.lower() in ("true", "yes"):
            return queryset.exclude(harvest__harvest_type='web')
        else:
            return queryset
Пример #16
0
class BoxListFilter(FilterSet):
    min_length = Filter(field_name="length", lookup_expr="gte")
    max_length = Filter(field_name="length", lookup_expr="lte")
    min_breadth = Filter(field_name="breadth", lookup_expr="gte")
    max_breadth = Filter(field_name="breadth", lookup_expr="lte")
    min_height = Filter(field_name="height", lookup_expr="gte")
    max_height = Filter(field_name="height", lookup_expr="lte")
    min_area = Filter(field_name="area", lookup_expr="gte")
    max_area = Filter(field_name="area", lookup_expr="lte")
    min_volume = Filter(field_name="volume", lookup_expr="gte")
    max_volume = Filter(field_name="volume", lookup_expr="lte")
    created_by = Filter(field_name="created_by_id", lookup_expr="exact")
    min_created_at = IsoDateTimeFilter(field_name='created_at', lookup_expr="gte")
    max_created_at = IsoDateTimeFilter(field_name='created_at', lookup_expr="lte")

    class Meta:
        model = Box
        fields = [
            'min_length', 'max_length', 'min_breadth', 'max_breadth',
            'min_area', 'max_area', 'min_volume', 'max_volume', 'created_by'
        ]
Пример #17
0
class HistoryFilter(_BaseFilter):
    playbook__not = CharFilter(method=name_filter)
    playbook = CharFilter(method=name_filter)
    start_time__gt = IsoDateTimeFilter(name="start_time", lookup_expr=('gt'))
    stop_time__gt = IsoDateTimeFilter(name="stop_time", lookup_expr=('gt'))
    start_time__lt = IsoDateTimeFilter(name="start_time", lookup_expr=('lt'))
    stop_time__lt = IsoDateTimeFilter(name="stop_time", lookup_expr=('lt'))
    start_time__gte = IsoDateTimeFilter(name="start_time", lookup_expr=('gte'))
    stop_time__gte = IsoDateTimeFilter(name="stop_time", lookup_expr=('gte'))
    start_time__lte = IsoDateTimeFilter(name="start_time", lookup_expr=('lte'))
    stop_time__lte = IsoDateTimeFilter(name="stop_time", lookup_expr=('lte'))

    class Meta:
        model = models.History
        fields = (
            'id',
            'playbook',
            'project',
            'status',
            'start_time',
            'stop_time',
        )
Пример #18
0
class TimestampMixin(FilterSet):

    # TODO(stephenfin): These should filter on a 'updated_at' field instead
    before = IsoDateTimeFilter(lookup_expr='lt', **{NAME_FIELD: 'date'})
    since = IsoDateTimeFilter(lookup_expr='gte', **{NAME_FIELD: 'date'})
Пример #19
0
class TimestampMixin(FilterSet):

    # TODO(stephenfin): These should filter on a 'updated_at' field instead
    before = IsoDateTimeFilter(name='date', **{LOOKUP_FIELD: 'lt'})
    since = IsoDateTimeFilter(name='date', **{LOOKUP_FIELD: 'gte'})
Пример #20
0
class TimestampMixin(FilterSet):

    # TODO(stephenfin): These should filter on a 'updated_at' field instead
    before = IsoDateTimeFilter(name='date', lookup_expr='lt')
    since = IsoDateTimeFilter(name='date', lookup_expr='gte')
Пример #21
0
class PostFilter(django_filters.FilterSet):
    start_date = IsoDateTimeFilter(field_name="created", lookup_expr='gte')
    end_date = IsoDateTimeFilter(field_name="created", lookup_expr='lte')
    description = CharFilter(field_name='description', lookup_expr='icontains')
    title = CharFilter(field_name='title', lookup_expr='icontains')