class DeathReportFilter(django_filters.FilterSet): location = LocationFilter(label='Location', queryset=Location.objects.all()) date_start = django_filters.DateFilter( name=u'date', label='Start date', lookup_expr=u'gte', widget=forms.DateInput(attrs={ u'class': u'form-control mb-2 mr-sm-2 mb-sm-0', u'placeholder': u'start'})) date_end = django_filters.DateFilter( name=u'date', label='End date', lookup_expr=u'lte', widget=forms.DateInput(attrs={ u'class': u'form-control mb-2 mr-sm-2 mb-sm-0', u'placeholder': u'end'}))
class XwgjYjsMxFilter(django_filters.FilterSet): kssj = django_filters.DateFilter(field_name="xwsj", lookup_expr='gte') jssj = django_filters.DateFilter(field_name="xwsj", lookup_expr='lte') class Meta: model = wm.YjsXwgjGrgj fields = [ 'id', 'xh', 'kssj', 'jssj', ]
class SprintFilter(django_filters.FilterSet): """Allows queries such as ?end_max=2014-08-01 for fetching date ranges""" end_min = django_filters.DateFilter(name='end', lookup_type='gte') end_max = django_filters.DateFilter(name='end', lookup_type='lte') class Meta: model = Sprint fields = ( 'end_min', 'end_max', )
class CohortFilter(django_filters.FilterSet): kind = django_filters.CharFilter(field_name="kind__code") start = django_filters.DateFilter(lookup_expr="gte") end = django_filters.DateFilter(lookup_expr="lte") class Meta: model = Cohort fields = ( "kind", "start", "end", )
class OrderFilter(django_filters.FilterSet): start_date = django_filters.DateFilter(field_name='date_created', lookup_expr='gte') end_date = django_filters.DateFilter(field_name='date_created', lookup_expr='lte') note = django_filters.CharFilter(field_name='note', lookup_expr='icontains') class Meta: model = Order fields = '__all__' exclude = ['customer', 'date_created']
class PluginFilter(FilterSet): min_creation_date = django_filters.DateFilter(name="creation_date", lookup_expr='gte') max_creation_date = django_filters.DateFilter(name="creation_date", lookup_expr='lte') class Meta: model = Plugin fields = [ 'name', 'dock_image', 'type', 'min_creation_date', 'max_creation_date' ]
class FeedFilter(FilterSet): min_id = django_filters.NumberFilter(field_name="id", lookup_expr='gte') max_id = django_filters.NumberFilter(field_name="id", lookup_expr='lte') min_creation_date = django_filters.DateFilter(field_name="creation_date", lookup_expr='gte') max_creation_date = django_filters.DateFilter(field_name="creation_date", lookup_expr='lte') class Meta: model = Feed fields = ['id', 'name', 'min_id', 'max_id', 'min_creation_date', 'max_creation_date']
class CohortFilter(django_filters.FilterSet): kind = django_filters.CharFilter(field_name='kind__code') start = django_filters.DateFilter(lookup_expr='gte') end = django_filters.DateFilter(lookup_expr='lte') class Meta: model = Cohort fields = ( 'kind', 'start', 'end', )
class DailyProductivityLogFilter(FilterSet): start_date = django_filters.DateFilter(name='date', lookup_expr='gte') end_date = django_filters.DateFilter(name='date', lookup_expr='lte') class Meta: model = DailyProductivityLog fields = [ 'uuid', 'date', 'source', 'very_productive_time_minutes', 'productive_time_minutes', 'neutral_time_minutes', 'distracting_time_minutes', 'very_distracting_time_minutes', 'start_date', 'end_date' ]
def create_task_viewset(model, serializer, fields): """Create a viewset for a task""" # pylint: disable=invalid-name Meta = type( 'Meta', (object, ), { 'model': model, 'fields': ( 'min_date_created', 'max_date_created', 'min_date_done', 'max_date_done', 'resolved', 'assigned', ) + fields }) filter_fields = dict( assigned=django_filters.CharFilter(name='assigned__username'), min_date_created=django_filters.DateFilter( name='date_created', lookup_expr='gte', ), max_date_created=django_filters.DateFilter( name='date_created', lookup_expr='lte', ), min_date_done=django_filters.DateFilter( name='date_done', lookup_expr='gte', ), max_date_done=django_filters.DateFilter( name='date_done', lookup_expr='lte', ), Meta=Meta, ) relation_fields = [ 'user', 'foia', 'communication', 'agency', 'jurisdiction' ] for rfield in relation_fields: if rfield in fields: filter_fields[rfield] = django_filters.NumberFilter(name='%s__id' % rfield) Filter = type('Filter', (django_filters.FilterSet, ), filter_fields) return type( (model.__name__ + 'ViewSet'), (viewsets.ModelViewSet, ), { 'queryset': model.objects.all(), 'serializer_class': serializer, 'permission_classes': (IsAdminUser, ), 'filter_class': Filter, })
class PluginInstanceFilter(FilterSet): min_start_date = django_filters.DateFilter(field_name='start_date', lookup_expr='gte') max_start_date = django_filters.DateFilter(field_name='start_date', lookup_expr='lte') min_end_date = django_filters.DateFilter(field_name='end_date', lookup_expr='gte') max_end_date = django_filters.DateFilter(field_name='end_date', lookup_expr='lte') title = django_filters.CharFilter(field_name='title', lookup_expr='icontains') owner_username = django_filters.CharFilter(field_name='owner__username', lookup_expr='exact') feed_id = django_filters.CharFilter(field_name='feed_id', lookup_expr='exact') root_id = django_filters.CharFilter(method='filter_by_root_id') plugin_id = django_filters.CharFilter(field_name='plugin_id', lookup_expr='exact') pipeline_inst_id = django_filters.CharFilter(field_name='pipeline_inst_id', lookup_expr='exact') plugin_name = django_filters.CharFilter(field_name='plugin__meta__name', lookup_expr='icontains') plugin_name_exact = django_filters.CharFilter( field_name='plugin__meta__name', lookup_expr='exact') plugin_version = django_filters.CharFilter(field_name='plugin__version', lookup_expr='exact') class Meta: model = PluginInstance fields = [ 'id', 'min_start_date', 'max_start_date', 'min_end_date', 'max_end_date', 'root_id', 'title', 'status', 'owner_username', 'feed_id', 'plugin_id', 'plugin_name', 'plugin_name_exact', 'plugin_version', 'pipeline_inst_id' ] def filter_by_root_id(self, queryset, name, value): """ Custom method to return the plugin instances in a queryset with a common root plugin instance. """ filtered_queryset = [] root_queryset = queryset.filter(pk=value) # check whether the root id value is in the DB if not root_queryset.exists(): return root_queryset queue = [root_queryset[0]] while len(queue) > 0: visited = queue.pop() queue.extend(list(visited.next.all())) filtered_queryset.append(visited) return filtered_queryset
class AgendaFilterSet(FilterSet): medico = MedicoSerializer() medico__especialidade = django_filters.ModelChoiceFilter( label="Especialidade", to_field_name='id', queryset=Especialidade.objects.all()) especialidade = medico__especialidade dia_inicio = django_filters.DateFilter(field_name='dia', lookup_expr='gt') dia_final = django_filters.DateFilter(field_name='dia', lookup_expr='lt') class Meta: model = Agenda fields = ['medico', 'especialidade', 'dia_inicio', 'dia_final']
class SaleStatsFilter(filters.FilterSet): id = ListFilter(name='id') date_field_start = django_filters.DateFilter(name="date_field", lookup_type='gte') date_field_end = django_filters.DateFilter(name="date_field", lookup_type='lte') class Meta: model = SaleStats fields = [ 'id', 'current_id', 'date_field', 'num', 'timely_type', 'record_type', 'status', 'date_field_start', 'date_field_end' ]
class CandidateFilter(django_filters.FilterSet): start_date = django_filters.DateFilter(name='created_at', lookup_expr=('gt'), widget=AdminDateWidget()) end_date = django_filters.DateFilter(name='created_at', lookup_expr=('lt'), widget=AdminDateWidget()) registry_year = django_filters.DateRangeFilter(field_name='created_at', lookup_expr='year') class Meta: model = Candidate fields = ['vendor', 'position_applied']
class VisitaFilter(filters.FilterSet): """Filtros para la visa de :class:`VisitaViewSet` """ fecha_min = django_filters.DateFilter(name='fecha', lookup_expr='gte') fecha_max = django_filters.DateFilter(name='fecha', lookup_expr='lte') municipio = django_filters.NumberFilter(name='escuela__municipio') departamento = django_filters.NumberFilter( name='escuela__municipio__departamento') class Meta: model = Visita fields = ['capacitador', 'fecha_min', 'fecha_max']
class ReportRemoteGoodsFilter(django_filters.FilterSet): start_date = django_filters.DateFilter( field_name="date", lookup_expr='gte', widget=DateInput(attrs={'type': 'date'})) end_date = django_filters.DateFilter( field_name="date", lookup_expr='lte', widget=DateInput(attrs={'type': 'date'})) class Meta: model = OTK exclude = ['date', 'nariad_code', 'goods_value', 'remote_value']
class SearchCheckoutGoodsFilter(django_filters.FilterSet): start_date = django_filters.DateFilter( field_name="date", lookup_expr='gte', widget=DateInput(attrs={'type': 'date'})) end_date = django_filters.DateFilter( field_name="date", lookup_expr='lte', widget=DateInput(attrs={'type': 'date'})) class Meta: model = CheckoutGoods exclude = ['customer_name', 'date', 'code_goods', 'values']
class EducationFilter(django_filters.FilterSet): start_year__gt = django_filters.DateFilter(field_name='start_date', lookup_expr='year__gte') end_year__lt = django_filters.DateFilter(field_name='end_date', lookup_expr='year__lte') end_year__lt = django_filters.DateRangeFilter class Meta: model = Education fields = { 'university', 'degree', }
class SearchSuppliersDeliveryFilter(django_filters.FilterSet): start_date = django_filters.DateFilter( field_name="date", lookup_expr='gte', widget=DateInput(attrs={'type': 'date'})) end_date = django_filters.DateFilter( field_name="date", lookup_expr='lte', widget=DateInput(attrs={'type': 'date'})) class Meta: model = DeliveriesMaterials exclude = ['supplier_name', 'date', 'code_material', 'values']
class BirthRegistrationFilter(django_filters.FilterSet): location = LocationFilter2(queryset=Location.objects.filter( type__name__in=[u'State', u'LGA'])) start_time = django_filters.DateFilter(name='time', lookup_expr='gte') end_time = django_filters.DateFilter(name='time', lookup_expr='lte') class Meta: model = BirthRegistration fields = ['location', 'start_time', 'end_time'] def __init__(self, *args, **kwargs): request = kwargs.pop('request', None) super(BirthRegistrationFilter, self).__init__(*args, **kwargs)
class EntryFilter(django_filters.rest_framework.FilterSet): min_date = django_filters.DateFilter(name="date", lookup_expr="gte") max_date = django_filters.DateFilter(name="date", lookup_expr="lte") class Meta: model = Entry fields = ( 'id', 'date', 'user', 'project', 'project__client', )
class DormRezerwacjeManageFilter(django_filters.FilterSet): data_od = django_filters.DateFilter(lookup_expr='contains', label="Data od") data_do = django_filters.DateFilter(lookup_expr='contains', label="Data do") id_pomieszczenia = django_filters.ModelChoiceFilter( queryset=Pokoj.objects.all(), label="Pokój ") id_uzytkownika = django_filters.ModelChoiceFilter( queryset=Uzytkownik.objects.all(), label="Użytkownik ") class Meta: model = RezerwacjaPokoju fields = '__all__'
class SoftwareFilter(django_filters.FilterSet): description = django_filters.CharFilter(lookup_type="icontains") begin__last_used = django_filters.DateFilter( name="softwareversion__last_used", lookup_type="gte") end_last_used = django_filters.DateFilter( name="softwareversion__last_used", lookup_type="lte") class Meta: model = Software fields = ('name', 'description', 'group', 'category', 'academic_only', 'restricted',)
class GroupFilter(django_filters.rest_framework.FilterSet): min_group_create_time = django_filters.DateFilter( field_name='group_create_time', lookup_expr='gte') max_group_create_time = django_filters.DateFilter( field_name='group_create_time', lookup_expr='lte') class Meta: model = Group fields = { 'group_id': ['exact'], 'group_name': ['icontains'], 'group_create_time': ['exact'], }
class SprintFilter(django_filters.FilterSet): # attention: changed to 'lookup_expr' # https://django-filter.readthedocs.io/en/master/ref/filters.html end_min = django_filters.DateFilter(field_name='end', lookup_expr='gte') end_max = django_filters.DateFilter(field_name='end', lookup_expr='lte') class Meta: model = Sprint fields = ( 'end_min', 'end_max', )
class RequestFilter(django_filters.FilterSet): get_request_type_display = django_filters.CharFilter( name="request_type", lookup_expr='icontains') added_date = django_filters.DateFilter(name="added", lookup_expr='contains') sent_date = django_filters.DateFilter(name="sent", lookup_expr='contains') get_status_display = django_filters.CharFilter(name="status", lookup_expr='icontains') class Meta: model = Request fields = ('get_request_type_display', 'added_date', 'sent_date', 'get_status_display')
class DailyOffItemFilter(django_filters.rest_framework.FilterSet): min_item_off_create_time = django_filters.DateFilter( field_name='item_off_create_time', lookup_expr='gte') max_item_off_create_time = django_filters.DateFilter( field_name='item_off_create_time', lookup_expr='lte') class Meta: model = DailyOffItem fields = { 'item_id': ['exact'], 'item_off_id': ['exact'], 'item_off_create_time': ['exact'], }
class SaleFilter(django_filters.FilterSet): From = django_filters.DateFilter(field_name="sale_date", lookup_expr="gte", label='From', widget=DatePicker()) To = django_filters.DateFilter(field_name="sale_date", lookup_expr="lte", label='To', widget=DatePicker()) class Meta: model = PatientInfo fields = ['bill_no', 'phone']
class TransactionFilter(django_filters.FilterSet): # account = django_filters.ModelChoiceFilter(queryset=Account.objects.all()) transaction_head = django_filters.ModelChoiceFilter(queryset=TransactionHead.objects.all()) # inout_type = django_filters.ChoiceFilter(choices=[('DR','Debit'),('CR','Credit')]) date_lt = django_filters.DateFilter(field_name='date', lookup_expr='lt',widget=forms.DateInput(format='%d/%m/%y'),input_formats=('%d/%m/%y', )) date_gt = django_filters.DateFilter(field_name='date', lookup_expr='gt',widget=forms.DateInput(format='%d/%m/%y'),input_formats=('%d/%m/%y', )) class Meta: model = Transaction fields = { # 'account':[], # 'inout_type':[], 'transaction_head':[], }
class DrugSearch(django_filters.FilterSet): start_date = django_filters.DateFilter(field_name='date_created', lookup_expr='gte', label='Records After', widget=DateInput()) exact_date = django_filters.DateFilter(field_name='date_created', lookup_expr='icontains', label='Records On', widget=DateInput()) class Meta: model = Safe fields = ['drug_name', 'start_date', 'exact_date']