コード例 #1
0
class DashboardSensorDataFilter(filters.FilterSet):
    station = filters.ModelChoiceFilter(
        label="Station",
        name="sensor__station_id",
        queryset=Station.objects.filter(current_status='ACTIVE'),
        widget=forms.Select)
    start_date = filters.IsoDateTimeFilter(
        label="Start Date",
        name="sensor_data_dateTime",
        lookup_expr='gte',
        widget=forms.DateTimeInput(attrs={'type': 'datetime-local'}))
    end_date = filters.IsoDateTimeFilter(
        label="End Date",
        name="sensor_data_dateTime",
        lookup_expr='lte',
        widget=forms.DateTimeInput(attrs={'type': 'datetime-local'}))
    sensor_type = filters.ModelChoiceFilter(label="Sensor Type *",
                                            name="sensor__sensor_type_id",
                                            queryset=SensorType.objects.all(),
                                            widget=forms.Select,
                                            required=True)
    order_by_field = 'ordering'
    ordering = OrderingFilter(
        # fields(('model field name', 'parameter name'),)
        fields=(('sensor_data_dateTime', 'sensor_data_dateTime')))

    class Meta:
        model = SensorData
        fields = ['start_date', 'end_date', 'station', 'sensor_type']
コード例 #2
0
ファイル: shop.py プロジェクト: samyka/E-Commerce
class ShopFilter(FilterSet):
    modified_before = django_filters.IsoDateTimeFilter(name="modified_on", lookup_expr='lt')
    modified_after = django_filters.IsoDateTimeFilter(name="modified_on", lookup_expr='gt')

    class Meta:
        model = Shop
        fields = ["id", "modified_before", "modified_after"]
コード例 #3
0
class PaymentFilter(FilterSet):
    batch_ref = django_filters.CharFilter(name='invoice__batch_ref',
                                          label='Invoice Batch Ref',
                                          lookup_expr='exact')
    number = django_filters.NumberFilter(name='invoice__number',
                                         label='Invoice number',
                                         lookup_expr='exact')
    project = django_filters.NumberFilter(name='invoice__project',
                                          label='Project Invoice',
                                          lookup_expr='exact')
    user = django_filters.NumberFilter(name='invoice__user',
                                       label='Invoice user',
                                       lookup_expr='exact')
    min_date = django_filters.IsoDateTimeFilter(name='paid_at',
                                                lookup_expr='gte')
    max_date = django_filters.IsoDateTimeFilter(name='paid_at',
                                                lookup_expr='lte')

    class Meta:
        model = Payment
        fields = (
            'min_date',
            'max_date',
            'batch_ref',
            'number',
            'user',
            'project',
            'created_by',
        )
コード例 #4
0
class PluginInstanceFileFilter(FilterSet):
    min_creation_date = django_filters.IsoDateTimeFilter(
        field_name='creation_date', lookup_expr='gte')
    max_creation_date = django_filters.IsoDateTimeFilter(
        field_name='creation_date', lookup_expr='lte')
    plugin_inst_id = django_filters.CharFilter(field_name='plugin_inst_id',
                                               lookup_expr='exact')
    feed_id = django_filters.CharFilter(field_name='plugin_inst__feed_id',
                                        lookup_expr='exact')
    fname = django_filters.CharFilter(field_name='fname',
                                      lookup_expr='startswith')
    fname_exact = django_filters.CharFilter(field_name='fname',
                                            lookup_expr='exact')
    fname_icontains = django_filters.CharFilter(field_name='fname',
                                                lookup_expr='icontains')
    fname_nslashes = django_filters.CharFilter(method='filter_by_n_slashes')

    class Meta:
        model = PluginInstanceFile
        fields = [
            'id', 'min_creation_date', 'max_creation_date', 'plugin_inst_id',
            'feed_id', 'fname', 'fname_exact', 'fname_icontains',
            'fname_nslashes'
        ]

    def filter_by_n_slashes(self, queryset, name, value):
        """
        Custom method to return the files that have the queried number of slashes in
        their fname property. If the queried number ends in 'u' or 'U' then only one
        file per each last "folder" in the path is returned (useful to efficiently get
        the list of immediate folders under the path).
        """
        return filter_files_by_n_slashes(queryset, value)
コード例 #5
0
ファイル: urls.py プロジェクト: unscrollinc/unscroll
class EventFilter(filters.FilterSet):

    start = django_filters.IsoDateTimeFilter(
        name='when_happened',
        lookup_expr='gte')

    before = django_filters.IsoDateTimeFilter(
        name='when_happened',
        lookup_expr='lte')

    order = django_filters.OrderingFilter(
        # tuple-mapping retains order
        fields = ['when_happened', 'ranking'])
    
    q = django_filters.CharFilter(method='filter_by_q', distinct=True)

    # TODO THIS THING IS FRANKLY REAL DODGY
    def filter_by_q(self, queryset, WHAT_IS_THIS_ARG_I_DO_NOT_KNOW, value):
        uq = unquote(value)
        apos = re.sub(r"[';]", "", uq)
        filtered_val = "'{}'".format(apos,)
        return queryset.full_text_search(filtered_val)

    class Meta:
        model = Event
        fields = ['start',
                  'before',
                  'q',
                  'in_scroll',
                  'in_scroll__slug',
                  'in_scroll__uuid',
                  'in_scroll__by_user__username']
コード例 #6
0
class Services_Filter(django_filters.FilterSet):
    search_param = django_filters.CharFilter( method = 'my_custom_filter' )
    #timestamp_gte = django_filters.DateTimeFilter( name = "created", lookup_expr = 'gte' )
    #timestamp_lte = django_filters.DateTimeFilter( name = "created", lookup_expr = 'lte' )
    #resolved = django_filters.DateTimeFilter( name = "timestamp", lookup_expr = 'lte' )
    timestamp_gte = django_filters.IsoDateTimeFilter(name = "created", lookup_expr = 'gte')
    timestamp_lte = django_filters.IsoDateTimeFilter(name = "created", lookup_expr = 'lte')
    class Meta:
        model = Services
        fields = [ 'search_param', 'created' ]
        #fields = {"search_param": ['iexact', 'icontains', 'in', 'startswith']}

        # filter_overrides = {
        # 	django_models.DateTimeField: {
        # 	'filter_class': django_filters.IsoDateTimeFilter
        # 	}

        # }

    def my_custom_filter( self, queryset, name, value ):
    	try:
    		return queryset.filter(
    			id = value
    			)
    	except:
    		return queryset.filter(
    			service_type = value.title()
    			)
コード例 #7
0
ファイル: helpers.py プロジェクト: loftsh/jardin
class PumpStateFilter(django_filters.FilterSet):
    class Meta:
        model = PumpState
        fields = ['date', 'state']

    date_gt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='gt')
    date_lt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='lt')
コード例 #8
0
    class HistoryFilter(filters.FilterSet):
        min_date = django_filters.IsoDateTimeFilter(field_name="revision__date_created", lookup_expr="gte")
        max_date = django_filters.IsoDateTimeFilter(field_name="revision__date_created", lookup_expr="lte")

        class Meta:
            model = Version
            fields = ['id', 'min_date', 'max_date']
コード例 #9
0
class Products_Filter(django_filters.FilterSet):
    timestamp_gte = django_filters.IsoDateTimeFilter( name = "created", lookup_expr = 'gte' )
    timestamp_lte = django_filters.IsoDateTimeFilter( name = "created", lookup_expr = 'lte' )
    search_param = django_filters.CharFilter( method = 'my_custom_filter' )
    has_open_process = django_filters.CharFilter( name = 'services__has_open_process', lookup_expr = 'iexact' )
    lacks_service_type = django_filters.CharFilter( name = 'services__service_type', lookup_expr = 'exact',exclude = True )
    #user = django_filters.NumberFilter( name = 'services__service_type', lookup_expr = 'exact', exclude = True )
    class Meta:
        model = Auction_Products
        fields = ['search_param', 'created', 'has_open_process', 'lacks_service_type', 'user']

    # def has_logistics(self, queryset, name, value):

    #     return queryset

    def my_custom_filter(self, queryset, name, value):
    	try:
    		products_query = queryset.filter(auction__host = value.lower())
    		if products_query.exists():
    			return products_query
    		raise Exception('No payment_type found')
    	except:
    		pass

    	try:
    		products_query = queryset.filter(lot_number = value)
    		if products_query.exists():
    			return products_query
    		raise Exception('No lot_number found')
    	except:
    		pass

    	return []
コード例 #10
0
class TripFilter(django_filters.FilterSet):
    pickupTime__gte = django_filters.IsoDateTimeFilter(name="pickupTime",
                                                       lookup_expr='gte')
    pickupTime__lte = django_filters.IsoDateTimeFilter(name="pickupTime",
                                                       lookup_expr='lte')
    pickupWeekday = django_filters.TypedMultipleChoiceFilter(
        choices=WEEKDAY_CHOICES, name="pickupTime__week_day")
    #pickupWeekday = django_filters.NumberFilter(method='weekday_filter')
    dropoffTime__gte = django_filters.IsoDateTimeFilter(name="dropoffTime",
                                                        lookup_expr='gte')
    dropoffTime__lte = django_filters.IsoDateTimeFilter(name="dropoffTime",
                                                        lookup_expr='lte')
    # dropoffWeekday = django_filters.MultipleChoiceFilter(choices=WEEKDAY_CHOICES,name="dropoffTime", lookup_expr='week_day')
    set = django_filters.NumberFilter(method='set_filter')

    class Meta:
        model = Trip
        fields = {
            'tripDistance': ['lte', 'gte'],
            'totalAmount': ['lte', 'gte'],
        }

    def set_filter(self, queryset, name, value):
        if value == 29:
            return queryset  #.filter(pickupDistrict__isnull=True,pickupPoint__isnull=False)
        return queryset.filter(set=value)
コード例 #11
0
class Payments_Filter(django_filters.FilterSet):
    timestamp_gte = django_filters.IsoDateTimeFilter( name = "created", lookup_expr = 'gte' )
    timestamp_lte = django_filters.IsoDateTimeFilter( name = "created", lookup_expr = 'lte' )
    search_param = django_filters.CharFilter(method='payment_custom_filter')
    class Meta:
        model = Payments
        fields = [ 'created', 'id', 'search_param' ]

    def payment_custom_filter(self, queryset, name, value):
    	
    	try:
    		payment_type_query = queryset.filter(payment_type = value.lower())
    		if payment_type_query.exists():
    			return payment_type_query
    		raise Exception('No payment_type found')
    	except:
    		pass

    	try:
    		payment_type_query = queryset.filter(id = value)
    		if payment_type_query.exists():
    			return payment_type_query
    		raise Exception('No payment_id found')
    	except:
    		pass	
    	# try:
    	# 	if value==''
    	# 	payment_type_query = queryset.filter(payment_approved = value)
    	# 	if payment_type_query.exists():
    	# 		return payment_type_query
    	# 	raise Exception('No payment_type found')
    	# except:
    	# 	return queryset.filter(pk = value)

    	return []
コード例 #12
0
class TyreMeasurementFilter(FilterSet):
    timestamp_min = django_filters.IsoDateTimeFilter(name='timestamp', lookup_expr='gte')
    timestamp_max = django_filters.IsoDateTimeFilter(name='timestamp', lookup_expr='lte')

    class Meta:
        model = TyreMeasurement
        fields = ('timestamp', 'car', 'position', 'timestamp_min', 'timestamp_max')
コード例 #13
0
ファイル: filter_set.py プロジェクト: metalica20/neoc
class AlertFilter(django_filters.FilterSet):
    started_on__gt = django_filters.IsoDateTimeFilter(
        field_name='started_on',
        lookup_expr='gte',
    )
    started_on__lt = django_filters.IsoDateTimeFilter(
        field_name='started_on',
        lookup_expr='lte',
    )
    created_on__gt = django_filters.IsoDateTimeFilter(
        field_name='created_on',
        lookup_expr='gte',
    )
    created_on__lt = django_filters.IsoDateTimeFilter(
        field_name='created_on',
        lookup_expr='lte',
    )
    hazard = django_filters.ModelMultipleChoiceFilter(
        queryset=Hazard.objects.all(),
        lookup_expr='in',
        widget=django_filters.widgets.CSVWidget,
    )

    class Meta:
        model = Alert
        fields = ['event', ]
コード例 #14
0
class PACSFileFilter(FilterSet):
    min_creation_date = django_filters.IsoDateTimeFilter(
        field_name='creation_date', lookup_expr='gte')
    max_creation_date = django_filters.IsoDateTimeFilter(
        field_name='creation_date', lookup_expr='lte')
    fname = django_filters.CharFilter(field_name='fname',
                                      lookup_expr='startswith')
    fname_exact = django_filters.CharFilter(field_name='fname',
                                            lookup_expr='exact')
    PatientName = django_filters.CharFilter(field_name='PatientName',
                                            lookup_expr='icontains')
    ProtocolName = django_filters.CharFilter(field_name='ProtocolName',
                                             lookup_expr='icontains')
    StudyDescription = django_filters.CharFilter(field_name='StudyDescription',
                                                 lookup_expr='icontains')
    SeriesDescription = django_filters.CharFilter(
        field_name='SeriesDescription', lookup_expr='icontains')
    pacs_identifier = django_filters.CharFilter(field_name='pacs__identifier',
                                                lookup_expr='exact')
    min_PatientAge = django_filters.NumberFilter(field_name='PatientAge',
                                                 lookup_expr='gte')
    max_PatientAge = django_filters.NumberFilter(field_name='PatientAge',
                                                 lookup_expr='lte')

    class Meta:
        model = PACSFile
        fields = [
            'id', 'min_creation_date', 'max_creation_date', 'fname',
            'fname_exact', 'PatientID', 'PatientName', 'PatientSex',
            'PatientAge', 'min_PatientAge', 'max_PatientAge',
            'PatientBirthDate', 'StudyDate', 'ProtocolName',
            'StudyInstanceUID', 'StudyDescription', 'SeriesInstanceUID',
            'SeriesDescription', 'pacs_identifier'
        ]
コード例 #15
0
class Estudios_Filter(django_filters.FilterSet):

    cedula = django_filters.NumberFilter(name="paciente__cedula",
                                         lookup_expr='iexact')
    result_present = django_filters.BooleanFilter(
        method='result_present_filter')
    results_printed = django_filters.BooleanFilter(
        method='results_printed_filter')
    timestamp_lte = django_filters.IsoDateTimeFilter(name="created",
                                                     lookup_expr='lte')
    timestamp_gte = django_filters.IsoDateTimeFilter(name="created",
                                                     lookup_expr='gte')
    patron = django_filters.NumberFilter(lookup_expr='exact')

    #resultadosnoimpresos  = django_filters.BooleanFilter(name='resultados__impreso')
    class Meta:
        model = Estudios
        fields = ['cedula', 'impreso', 'timestamp_lte', 'timestamp_gte']

    def filter_patron(self, queryset, name, value):
        return queryset.filter(patron=value)

    def result_present_filter(self, queryset, name, value):
        return queryset.filter(estudios__isnull=True).exists()

    def results_printed_filter(self, estudios, name, value):
        #print estudios.filter(resultados__isnull=True)
        return estudios.filter(
            Q(resultados__isnull=True) | Q(resultados__impreso=False))
コード例 #16
0
ファイル: helpers.py プロジェクト: loftsh/jardin
class WaterLevelFilter(django_filters.FilterSet):
    class Meta:
        model = WaterLevel
        fields = ['date', 'bac', 'level']

    date_gt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='gt')
    date_lt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='lt')
コード例 #17
0
ファイル: helpers.py プロジェクト: loftsh/jardin
class TemperatureFilter(django_filters.FilterSet):
    class Meta:
        model = Temperature
        fields = ['date', 'temperature']

    date_gt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='gt')
    date_lt = django_filters.IsoDateTimeFilter(name="date", lookup_expr='lt')
コード例 #18
0
class SubscriptionFilter(filters.FilterSet):
    created_after = django_filters.IsoDateTimeFilter(name="created_at",
                                                     lookup_type="gte")
    created_before = django_filters.IsoDateTimeFilter(name="created_at",
                                                      lookup_type="lte")

    class Meta:
        model = Subscription
コード例 #19
0
ファイル: filters.py プロジェクト: Adyrhan/hopestarterapp
class LocationMarkFilterSet(FilterSet):
    after = django_filters.IsoDateTimeFilter(name="created", lookup_expr='gte')
    before = django_filters.IsoDateTimeFilter(name="created",
                                              lookup_expr='lte')

    class Meta:
        model = LocationMark
        fields = ['created', 'user']
コード例 #20
0
class RecordFilter(filters.FilterSet):
    user = django_filters.CharFilter(name="user__username")
    from_date = django_filters.IsoDateTimeFilter(name="time", lookup_type='gte')
    to_date = django_filters.IsoDateTimeFilter(name="time", lookup_type='lte')

    class Meta:
        model = Record
        fields = ['user', 'from_date', 'to_date']
コード例 #21
0
ファイル: filters.py プロジェクト: estuans/satnogs-network
class ObservationViewFilter(django_filters.FilterSet):
    start = django_filters.IsoDateTimeFilter(name='start', lookup_expr='gte')
    end = django_filters.IsoDateTimeFilter(name='end', lookup_expr='lte')
    norad = django_filters.NumberFilter(name='satellite__norad_cat_id',
                                        lookup_expr='iexact')

    class Meta:
        model = Observation
        fields = ['ground_station']
コード例 #22
0
ファイル: hearing.py プロジェクト: vikoivun/kerrokantasi
class HearingFilter(django_filters.FilterSet):
    open_at_lte = django_filters.IsoDateTimeFilter(name='open_at',
                                                   lookup_type='lte')
    open_at_gt = django_filters.IsoDateTimeFilter(name='open_at',
                                                  lookup_type='gt')

    class Meta:
        model = Hearing
        fields = ['published', 'open_at_lte', 'open_at_gt']
コード例 #23
0
ファイル: filters.py プロジェクト: latest-release/tunga-api
class TimeEntryFilter(GenericDateFilterSet):
    min_date = django_filters.IsoDateTimeFilter(name='spent_at', lookup_expr='gte')
    max_date = django_filters.IsoDateTimeFilter(name='spent_at', lookup_expr='lte')
    min_hours = django_filters.IsoDateTimeFilter(name='hours', lookup_expr='gte')
    max_hours = django_filters.IsoDateTimeFilter(name='hours', lookup_expr='lte')

    class Meta:
        model = TimeEntry
        fields = ('user', 'task', 'spent_at', 'hours')
コード例 #24
0
ファイル: utils.py プロジェクト: antidot101/task_manager
class TaskFilter(FilterSet):
    min_date = django_filters.IsoDateTimeFilter(field_name="completion_date",
                                                lookup_expr="gte")
    max_date = django_filters.IsoDateTimeFilter(field_name="completion_date",
                                                lookup_expr="lte")

    class Meta:
        model = Task
        fields = ['id', 'status', 'completion_date']
コード例 #25
0
ファイル: filters.py プロジェクト: th3architect/ara-1
class DateFilter(BaseFilter):
    started_before = django_filters.IsoDateTimeFilter(field_name="started",
                                                      lookup_expr="lte")
    started_after = django_filters.IsoDateTimeFilter(field_name="started",
                                                     lookup_expr="gte")
    ended_before = django_filters.IsoDateTimeFilter(field_name="ended",
                                                    lookup_expr="lte")
    ended_after = django_filters.IsoDateTimeFilter(field_name="ended",
                                                   lookup_expr="gte")
コード例 #26
0
class ExampleFilter(django_filters.FilterSet):
    created_at__gte = django_filters.IsoDateTimeFilter(field_name='created_at', lookup_expr='gte')
    created_at__lte = django_filters.IsoDateTimeFilter(field_name='created_at', lookup_expr='lte')

    class Meta:
        model = Address
        fields = [
            'created_by'
        ]
コード例 #27
0
class Facturas_Filter(django_filters.FilterSet):
    timestamp_lte = django_filters.IsoDateTimeFilter(name="created",
                                                     lookup_expr='lte')
    timestamp_gte = django_filters.IsoDateTimeFilter(name="created",
                                                     lookup_expr='gte')

    class Meta:
        model = Facturas
        fields = ['id', 'creador', 'created', 'monto', 'descuento']
コード例 #28
0
class PondBlockFilter(mixins.CustomIsoDateTimeFilterMixin,
                      django_filters.FilterSet):
    site = django_filters.MultipleChoiceFilter(
        choices=configdb.get_site_tuples())
    observatory = django_filters.MultipleChoiceFilter(
        choices=configdb.get_enclosure_tuples(), field_name='enclosure')
    telescope = django_filters.MultipleChoiceFilter(
        choices=configdb.get_telescope_tuples())
    start_after = django_filters.IsoDateTimeFilter(
        field_name='start',
        lookup_expr='gte',
        label='Start after',
        widget=forms.TextInput(attrs={
            'class': 'input',
            'type': 'date'
        }))
    start_before = django_filters.IsoDateTimeFilter(
        field_name='start',
        lookup_expr='lt',
        label='Start before',
        widget=forms.TextInput(attrs={
            'class': 'input',
            'type': 'date'
        }))
    end_after = django_filters.IsoDateTimeFilter(field_name='end',
                                                 lookup_expr='gte',
                                                 label='End after')
    end_before = django_filters.IsoDateTimeFilter(field_name='end',
                                                  lookup_expr='lt',
                                                  label='End before')
    modified_after = django_filters.IsoDateTimeFilter(field_name='modified',
                                                      lookup_expr='gte',
                                                      label='Modified After')
    request_num = django_filters.CharFilter(field_name='request__id')
    tracking_num = django_filters.CharFilter(
        field_name='request__request_group__id')
    proposal = django_filters.CharFilter(
        field_name='request__request_group__proposal__id',
        distinct=True,
        lookup_expr='exact')
    instrument_class = django_filters.ChoiceFilter(
        choices=configdb.get_instrument_type_tuples(),
        field_name='configuration_statuses__configuration__instrument_type')
    canceled = django_filters.BooleanFilter(method='filter_canceled')
    order = django_filters.OrderingFilter(fields=('start', 'modified'))
    time_span = django_filters.DateRangeFilter(field_name='start')

    class Meta:
        model = Observation
        exclude = ['start', 'end', 'request', 'created', 'modified']

    def filter_canceled(self, queryset, name, value):
        if not value:
            return queryset.exclude(state='CANCELED')
        else:
            return queryset
コード例 #29
0
class HearingFilter(django_filters.rest_framework.FilterSet):
    open_at_lte = django_filters.IsoDateTimeFilter(name='open_at', lookup_expr='lte')
    open_at_gt = django_filters.IsoDateTimeFilter(name='open_at', lookup_expr='gt')
    title = django_filters.CharFilter(lookup_expr='icontains', name='translations__title', distinct=True)
    label = django_filters.Filter(name='labels__id', lookup_expr='in', distinct=True,
                                  widget=django_filters.widgets.CSVWidget)

    class Meta:
        model = Hearing
        fields = ['published', 'open_at_lte', 'open_at_gt', 'title', 'label']
コード例 #30
0
ファイル: order.py プロジェクト: matthiasnattke/pretix
    class OrderFilter(FilterSet):
        email = django_filters.CharFilter(field_name='email', lookup_expr='iexact')
        code = django_filters.CharFilter(field_name='code', lookup_expr='iexact')
        status = django_filters.CharFilter(field_name='status', lookup_expr='iexact')
        modified_since = django_filters.IsoDateTimeFilter(field_name='last_modified', lookup_expr='gte')
        created_since = django_filters.IsoDateTimeFilter(field_name='datetime', lookup_expr='gte')

        class Meta:
            model = Order
            fields = ['code', 'status', 'email', 'locale', 'testmode', 'require_approval']