Example #1
0
class BookingFilters(filters.FilterSet):
    lr_number = ListFilter(field_name='lr_numbers__id', label="Lr Number")
    shipment_date_between = filters.DateFromToRangeFilter(
        field_name="shipment_date",
        label="Shipment date Between",
        lookup_expr='range')
    charged_weight_range = filters.NumericRangeFilter(
        field_name="charged_weight",
        label="charged_weight_Range",
        lookup_expr='range')
    party_rate_range = filters.NumericRangeFilter(field_name="party_rate",
                                                  label="party_rate_Range",
                                                  lookup_expr='range')
    total_amount_to_company_range = filters.NumericRangeFilter(
        field_name="total_amount_to_company",
        label="total_amount_to_company_Range",
        lookup_expr='range')

    vehicle_id = ListFilter(field_name='vehicle_id', label='vehicle')

    source_office_id = ListFilter(field_name='source_office_id',
                                  label='Source Office')
    destination_office_id = ListFilter(field_name='destination_office_id',
                                       label='Destination Office')
    to_city_fk_id = ListFilter(field_name='to_city_fk_id', label='To City')
    from_city_fk_id = ListFilter(field_name='from_city_fk_id',
                                 label='From City')

    class Meta:
        model = ManualBooking
        fields = []
Example #2
0
class PostFilter(filters.FilterSet):
    date__gte = filters.NumericRangeFilter(field_name="pub_date",
                                           lookup_expr='gte')
    date__lte = filters.NumericRangeFilter(field_name="pub_date",
                                           lookup_expr='lte')

    class Meta:
        model = Post
Example #3
0
class IngredientRangeFilter(filters.FilterSet):
    min_number = filters.NumericRangeFilter(field_name="number",
                                            lookup_expr='gte')
    max_number = filters.NumericRangeFilter(field_name="number",
                                            lookup_expr='lte')

    class Meta:
        model = Ingredient
        fields = ['title']
Example #4
0
class SucursalFilter(filters.FilterSet):
    latitud = filters.NumericRangeFilter(field_name='latitud',
                                         lookup_expr='range')
    longitud = filters.NumericRangeFilter(field_name='longitud',
                                          lookup_expr='range')

    class Meta:
        model = Sucursal
        fields = ('empresa', 'municipio', 'latitud', 'longitud')
Example #5
0
class ContractRouteFilter(filters.FilterSet):
    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")
    source = filters.CharFilter(name="source__name",
                                label="Source City name",
                                lookup_expr="icontains")
    source_null = filters.BooleanFilter(name="source",
                                        label="Is Source name Null",
                                        lookup_expr='isnull')

    destination = filters.CharFilter(name="destination__name",
                                     label="Destination name",
                                     lookup_expr="icontains")
    destination_null = filters.BooleanFilter(name="destination",
                                             label="Is Destination name Null",
                                             lookup_expr="isnull")

    rate_type = filters.CharFilter(name="rate_type__name",
                                   label="Rate Type name",
                                   lookup_expr="icontains")
    rate_type_null = filters.BooleanFilter(name="rate_type",
                                           label="Is Rate Type name Null",
                                           lookup_expr="isnull")

    rate_range = filters.NumericRangeFilter(name="rate", label="Rate Range")
    created_on = filters.IsoDateTimeFilter(name="created_on",
                                           label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(
        name="created_on", label="Created Between")

    class Meta:
        model = ContractRoute
        fields = []
Example #6
0
class TipoColaFilter(filters.FilterSet):
    capacidad = filters.NumericRangeFilter(field_name='capacidad',
                                           lookup_expr='range')

    class Meta:
        model = TipoCola
        fields = ('empresa', 'capacidad')
Example #7
0
class StudentFilter(filters.FilterSet):
    birthdate = filters.DateFromToRangeFilter()
    att_score = filters.NumericRangeFilter(lookup_expr='range')
    examins_score = filters.NumericRangeFilter(lookup_expr='range')

    spec_name = filters.CharFilter(method='filter_direction')
    colledge_name = filters.CharFilter(method='filter_colledge')
    prof_name = filters.CharFilter(method='filter_prof')

    def filter_direction(self, queryset, name, values):
        fil = Q()
        for value in values.split(','):
            for direction in DirectionModel.objects.filter(
                    spec_name=value.strip()):
                fil |= Q(direction=direction)
        return queryset.filter(fil)

    def filter_colledge(self, queryset, name, values):
        fil = Q()
        for value in values.split(','):
            for direction in DirectionModel.objects.filter(
                    colledge_name=value.strip()):
                fil |= Q(direction=direction)
        return queryset.filter(fil)

    def filter_prof(self, queryset, name, values):
        fil = Q()
        for value in values.split(','):
            for direction in DirectionModel.objects.filter(
                    prof_name=value.strip()):
                fil |= Q(direction=direction)
        return queryset.filter(fil)

    o = filters.OrderingFilter(fields=(
        ('birthdate', 'birthdate'),
        ('att_score', 'att_score'),
        ('receipt_date', 'receipt_date'),
        ('current_curse', 'current_curse'),
    ))

    class Meta:
        model = StudentModel
        fields = [
            'birthdate', 'att_score', 'examins_score', 'is_disabled',
            'is_orphan', 'is_served', 'needs_home', 'region', 'male',
            'spec_name', 'colledge_name', 'prof_name'
        ]
Example #8
0
class EventFilter(filters.FilterSet):
    datetime_after = filters.DateTimeFilter(
        field_name="datetime_created",
        lookup_expr='gte',
        label="After datetime (e.g. 2018-12-08T16:24:10)")
    datetime_before = filters.DateTimeFilter(
        field_name="datetime_created",
        lookup_expr='lte',
        label="Before datetime (e.g. 2018-12-08T16:24:10)")
    latitude = filters.NumericRangeFilter(field_name="latitude",
                                          widget=RangeWidget())
    longitude = filters.NumericRangeFilter(field_name="longitude",
                                           widget=RangeWidget())

    class Meta:
        model = Event
        fields = [
            'country_name', 'country_iso', 'latitude', 'longitude', 'city',
            'datetime_before', 'datetime_after'
        ]
Example #9
0
class PatientFilterSet(filters.FilterSet):
    source = filters.ChoiceFilter(choices=PatientRegistration.SourceChoices)
    disease_status = CareChoiceFilter(choice_dict=DISEASE_STATUS_DICT)
    facility = filters.UUIDFilter(field_name="facility__external_id")
    phone_number = filters.CharFilter(field_name="phone_number")
    allow_transfer = filters.BooleanFilter(field_name="allow_transfer")
    name = filters.CharFilter(field_name="name", lookup_expr="icontains")
    ip_no = filters.CharFilter(field_name="last_consultation__ip_no", lookup_expr="icontains")
    gender = filters.BooleanFilter(field_name="gender")
    age = filters.NumericRangeFilter(field_name="age")
    category = filters.ChoiceFilter(field_name="last_consultation__category", choices=CATEGORY_CHOICES)
Example #10
0
class ProjectFilter(filters.FilterSet):
    client_name = filters.ModelChoiceFilter(field_name='client_name',
                                            queryset=Client.objects.all())
    date_line = filters.DateFilter(field_name='date_line')
    is_active = filters.BooleanFilter(field_name='is_active')
    budget = filters.NumericRangeFilter(field_name='budget')
    status = filters.ChoiceFilter(field_name='pay_purpose',
                                  choices=Evolution.task_status())

    class Meta:
        model = Project
        fields = ['client_name', 'date_line', 'is_active', 'status', 'budget']
Example #11
0
class UserFilter(filters.FilterSet):
    """User filter class."""

    min_reputation = filters.NumericRangeFilter()

    class Meta:
        """Meta class."""
        model = User
        fields = (
            'username',
            'profile__verified',
            'profile__born_date',
            # 'profile__profile_worker__reputation',
        )
Example #12
0
class ProfessionalListFilterSet(filters.FilterSet):
    """The filter class for the professional list viewset class."""

    pk_in = NumberInFilter(field_name="id", lookup_expr="in")
    experience = filters.NumericRangeFilter(
        field_name="experience",
        lookup_expr="range",
    )

    class Meta:
        """The professional list filterset class serializer META class."""

        model = Professional
        fields = ("pk_in", "subcategory", "subcategory__category", "level")
Example #13
0
class ModelFilter(filters.FilterSet):
    vendor = filters.CharFilter(field_name='vendor', lookup_expr='icontains')
    model_number = filters.CharFilter(field_name='model_number',
                                      lookup_expr='icontains')
    height = filters.NumericRangeFilter(field_name='height',
                                        lookup_expr='range')
    color = filters.CharFilter(field_name='display_color',
                               lookup_expr='iexact')
    network_ports_num = filters.NumericRangeFilter(
        field_name='network_ports_num', lookup_expr='range')
    power_ports = filters.NumericRangeFilter(field_name='power_ports',
                                             lookup_expr='range')
    cpu = filters.CharFilter(field_name='cpu', lookup_expr='icontains')
    memory = filters.NumericRangeFilter(field_name='memory',
                                        lookup_expr='range')
    storage = filters.CharFilter(field_name='storage', lookup_expr='icontains')
    comment = filters.CharFilter(field_name='comment', lookup_expr='icontains')

    class Meta:
        model = Model
        fields = [
            'vendor', 'model_number', 'height', 'color', 'network_ports_num',
            'power_ports', 'cpu', 'memory', 'storage', 'comment'
        ]
Example #14
0
class VehicleFilter(filters.FilterSet):
    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")
    owner = ListFilter(name="suppliervehicle__supplier_id", label="Owner name")
    owner_null = filters.BooleanFilter(name="supplier", label="Is Owner Null", lookup_expr="isnull")
    vehicle_number = filters.CharFilter(name="vehicle_number", label="Vehicle Number", lookup_expr='icontains')

    vehicle_type = filters.NumberFilter(name="vehicle_type__id", label="Vehicle Type", lookup_expr='exact')
    vehicle_type_null = filters.BooleanFilter(name="vehicle_type", label="Is Vehicle Type Null", lookup_expr="isnull")

    vehicle_capacity = filters.NumberFilter(name="vehicle_capacity", label="vehicle Capacity", lookup_expr='icontains')
    vehicle_capacity_range = filters.NumericRangeFilter(name="vehicle_capacity", label="vehicle Capacity")

    chassis_number = filters.CharFilter(name="chassis_number", label="Chasis Number", lookup_expr='icontains')
    chassis_number_null = filters.BooleanFilter(name="chassis_number", label="Is Chasis Number Null",
                                                lookup_expr="isnull")
    engine_number = filters.CharFilter(name="engine_number", label="Engine Number", lookup_expr='icontains')
    engine_number_null = filters.BooleanFilter(name="engine_number", label="Is Engine Number Null",
                                               lookup_expr="isnull")

    registration_year = filters.DateFilter(name="registration_year", label="Registration year", lookup_expr='icontains')
    registration_year_null = filters.BooleanFilter(name="registration_year", label="Is Registration Year Null",
                                                   lookup_expr="isnull")
    registration_year_range = filters.DateFromToRangeFilter(name="registration_year", label="Registration Year range")

    registration_validity = filters.DateFilter(name="registration_validity", label="Registration Validity",
                                               lookup_expr='icontains')
    registration_validity_range = filters.DateFromToRangeFilter(name="registration_validity",
                                                                label="Registration Validity Range")

    gps_enabled = filters.BooleanFilter(name="gps_enabled", label="Is GPS Enable", lookup_expr="exact")

    created_by = filters.CharFilter(name="created_by__username", label="Created By name", lookup_expr="icontains")
    created_by_null = filters.BooleanFilter(name="created_by", label="Is Created By Null", lookup_expr="isnull")

    created_on = filters.IsoDateTimeFilter(name="created_on", label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(name="created_on", label="Created Between")

    class Meta:
        model = Vehicle
        fields = []
Example #15
0
class SmeFilter(filters.FilterSet):
    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")

    name = filters.CharFilter(name="name__username",
                              label="Sme name",
                              lookup_expr='icontains')
    name_null = filters.BooleanFilter(name="name",
                                      label="Is Name Null",
                                      lookup_expr="isnull")
    company_name = filters.CharFilter(name="name__profile__name",
                                      label="Customer name",
                                      lookup_expr='icontains')

    email_tasks = filters.CharFilter(name='email_tasks__name',
                                     label="Name of Email Task",
                                     lookup_expr="icontains")
    company_code = filters.CharFilter(name='company_code',
                                      label="Company Code",
                                      lookup_expr="iexact")
    company_code_null = filters.BooleanFilter(name="company_code",
                                              label="Is Company Code Null",
                                              lookup_expr="isnull")

    latest_lr_serial_number = filters.NumberFilter(
        name="latest_lr_serial_number", label="Latest LR Serial Number")
    latest_lr_serial_number_between = filters.NumericRangeFilter(
        name="latest_lr_serial_number",
        label="Latest LR Serial Number Between")

    lr_format_type = filters.ChoiceFilter(name="lr_format_type",
                                          choices=LR_FORMAT_CHOICE)

    address = filters.CharFilter(name="address__line1",
                                 label="Sme address",
                                 lookup_expr='icontains')
    address_null = filters.BooleanFilter(name="address",
                                         label="Is Address Null",
                                         lookup_expr="isnull")

    customer_address = filters.CharFilter(name="customer_address",
                                          label="Customer Address")
    customer_address_null = filters.BooleanFilter(
        name="customer_address",
        label="Is Customer Address Null",
        lookup_expr="isnull")

    credit_period = filters.CharFilter(name="credit_period",
                                       label="Credit Period",
                                       lookup_expr='icontains')
    credit_period_null = filters.BooleanFilter(name="credit_period",
                                               label="Credit Period",
                                               lookup_expr="isnull")

    aaho_poc = ListFilter(name="aaho_poc__id", label="Aaho POC")
    aaho_poc_null = filters.BooleanFilter(name="aaho_poc",
                                          label="Is Aaho POC Null",
                                          lookup_expr="isnull")

    city = filters.CharFilter(name="city__name",
                              label="City Name",
                              lookup_expr='icontains')
    city_null = filters.BooleanFilter(name="city",
                                      label="Is City Null",
                                      lookup_expr="isnull")

    pin = filters.CharFilter(name="pin", label="PIN", lookup_expr='icontains')
    pin_null = filters.BooleanFilter(name="pin",
                                     label="Is PIN Null",
                                     lookup_expr="isnull")

    gstin = filters.CharFilter(name="gstin",
                               label="GSTIN",
                               lookup_expr='icontains')
    gstin_null = filters.BooleanFilter(name="gstin",
                                       label="Is GSTIN Null",
                                       lookup_expr="isnull")

    is_gst_applicable = filters.ChoiceFilter(name="is_gst_applicable",
                                             label="Is GST Applicable",
                                             choices=IS_GST_APPLICABLE_CHOICE)

    id_proof = filters.CharFilter(name="id_proof",
                                  label="ID Proof",
                                  lookup_expr='icontains')
    id_proof_null = filters.BooleanFilter(name="id_proof",
                                          label="Is ID Proof Null",
                                          lookup_expr="isnull")
    account_details_null = filters.BooleanFilter(
        name="account_details",
        label="Is Account Details Null",
        lookup_expr="isnull")
    account_number = filters.CharFilter(name="account_details__acount_number",
                                        label="Account Number",
                                        lookup_expr='exact')
    bank_name = filters.CharFilter(name="account_details__bank",
                                   label="Bank Name",
                                   lookup_expr='icontains')
    ifsc = filters.CharFilter(name="account_details__ifsc",
                              label="IFSC Code",
                              lookup_expr='icontains')

    service_tax_number = filters.CharFilter(
        name="taxation_details__service_tax_number",
        label="Service Tax Number",
        lookup_expr='exact')
    taxation_details_null = filters.BooleanFilter(
        name="taxation_details",
        label="Is Taxation Details Null",
        lookup_expr="isnull")

    status = filters.ChoiceFilter(name="status",
                                  choices=(('active', 'active'), ('inactive',
                                                                  'inactive')),
                                  label="Status")

    created_on = filters.IsoDateTimeFilter(name="created_on",
                                           label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(
        name="created_on", label="Created Between")

    # Reverse relations
    cheque_number = filters.CharFilter(name="cheque_files__cheque_number",
                                       label="Cheque Files Cheque Number",
                                       lookup_expr="icontains")
    cheque_date = filters.DateFilter(name="cheque_files__cheque_date",
                                     label="Cheque Files Cheque Date")
    serial = filters.CharFilter(name="cheque_files__serial",
                                label="Cheque Files Serial",
                                lookup_expr="icontains")

    aaho_office = ListFilter(field_name='aaho_office_id', label="Aaho Office")
    aaho_office_null = filters.NumberFilter(field_name='aaho_office',
                                            label="Aaho Office",
                                            lookup_expr='isnull')

    class Meta:
        model = Sme
        fields = []
Example #16
0
class ChequeFileFilter(filters.FilterSet):
    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")

    uploaded_by = filters.CharFilter(name="uploaded_by__username",
                                     label="Uploaded By name",
                                     lookup_expr="icontains")
    uploaded_by_null = filters.BooleanFilter(name="uploaded_by",
                                             label="Is Uploaded By Null",
                                             lookup_expr="isnull")

    resolved_by = filters.CharFilter(name="resolved_by__username",
                                     label="Resolved By name",
                                     lookup_expr="icontains")
    resolved_by_null = filters.BooleanFilter(name="resolved_by",
                                             label="Is Resolved By Null",
                                             lookup_expr="isnull")

    customer_name = filters.CharFilter(name="customer_name",
                                       label="Customer Name",
                                       lookup_expr="icontains")
    customer_name_null = filters.BooleanFilter(name="customer_name",
                                               label="Is Customer Name Null",
                                               lookup_expr="isnull")

    customer_null = filters.BooleanFilter(name="customer",
                                          label="Is Customer Null",
                                          lookup_expr="isnull")
    customer = filters.CharFilter(name="customer__name__username",
                                  label="Customer",
                                  lookup_expr="icontains")

    amount = filters.NumberFilter(name="amount",
                                  label="Amount",
                                  lookup_expr="exact")
    amount_between = filters.NumericRangeFilter(name="amount",
                                                label="Amount Range")

    cheque_number_null = filters.BooleanFilter(name="cheque_number",
                                               label="Is Cheque Number Null",
                                               lookup_expr="isnull")
    cheque_number = filters.CharFilter(name="cheque_number",
                                       label="Cheque Number",
                                       lookup_expr="icontains")

    cheque_date_null = filters.BooleanFilter(name="cheque_date",
                                             label="Is Cheque Date Null",
                                             lookup_expr="isnull")
    cheque_date = filters.DateFilter(name="cheque_date", label="Cheque Date ")
    cheque_date_between = filters.DateTimeFromToRangeFilter(
        name="cheque_date", label="Cheque Date Between")

    remarks = filters.CharFilter(name="remarks",
                                 label="Remarks",
                                 lookup_expr='icontains')
    remarks_null = filters.BooleanFilter(name="remarks",
                                         label="Is Remarks Null",
                                         lookup_expr="isnull")

    s3_upload = filters.CharFilter(name="s3_upload__filename",
                                   label="S3 Upload Filename",
                                   lookup_expr='icontains')
    s3_upload_null = filters.BooleanFilter(name="s3_upload",
                                           label="Is S3 Upload",
                                           lookup_expr="isnull")

    serial = filters.CharFilter(name="serial",
                                label="Serial Url",
                                lookup_expr='icontains')

    resolved = filters.BooleanFilter(name="resolved",
                                     label="Resolved",
                                     lookup_expr='exact')

    is_valid = filters.BooleanFilter(name="is_valid",
                                     label="Is Valid",
                                     lookup_expr='exact')

    resolved_datetime = filters.IsoDateTimeFilter(name="resolved_datetime",
                                                  label="resolved datetime")
    resolved_datetime_between = filters.DateTimeFromToRangeFilter(
        name="resolved_datetime", label="resolved Datetime Between")

    created_by = filters.CharFilter(name="created_by__username",
                                    label="Created By name",
                                    lookup_expr="icontains")
    created_by_null = filters.BooleanFilter(name="created_by",
                                            label="Is Created By Null",
                                            lookup_expr="isnull")

    created_on = filters.IsoDateTimeFilter(name="created_on",
                                           label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(
        name="created_on", label="Created Between")

    class Meta:
        model = ChequeFile
        fields = []
Example #17
0
class RequirementFilter(filters.FilterSet):
    REQ_STATUS = (
        ('open', 'Open'),
        ('cancelled', 'Cancelled'),
        ('fulfilled', 'Fulfilled'),
        ('unverified', 'Unverified'),
        ('lapsed', 'Lapsed'),
    )

    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")

    client = filters.CharFilter(name="client__name__username", label=" Client", lookup_expr='icontains')

    client_null = filters.BooleanFilter(name="client", label="Is Client Null", lookup_expr="isnull")

    from_shipment_date = filters.DateFilter(field_name="from_shipment_date", label="from_shipment_date")
    from_shipment_date_between = filters.DateFromToRangeFilter(field_name="from_shipment_date",
                                                               label="from_shipment_date Between")
    from_shipment_date_null = filters.BooleanFilter(field_name="from_shipment_date", label="Is from_shipment_date Null",
                                                    lookup_expr="isnull")

    to_shipment_date = filters.DateFilter(field_name="to_shipment_date", label="to_shipment_date")
    to_shipment_date_between = filters.DateFromToRangeFilter(field_name="to_shipment_date",
                                                             label="to_shipment_date Between")
    to_shipment_date_null = filters.BooleanFilter(field_name="to_shipment_date", label="Is to_shipment_date Null",
                                                  lookup_expr="isnull")

    from_city = filters.CharFilter(field_name="from_city__name", label="From City", lookup_expr="icontains")
    from_city_null = filters.BooleanFilter(field_name="from_city", label="Is From City Null",
                                           lookup_expr="isnull")

    to_city = filters.CharFilter(field_name="to_city__name", label="to_city", lookup_expr="icontains")
    to_city_null = filters.BooleanFilter(field_name="to_city", label="Is to_city Null", lookup_expr="isnull")

    aaho_office = filters.CharFilter(name="aaho_office__branch_name", label="Aaho Office", lookup_expr='icontains')
    aaho_office_id = filters.NumberFilter(name="aaho_office__id", label="Aaho Office ID", lookup_expr='exact')
    aaho_office_null = filters.BooleanFilter(name="aaho_office", label="Is Aaho Office Null", lookup_expr="isnull")

    tonnage = filters.NumberFilter(field_name="tonnage", label="tonnage")
    tonnage_range = filters.NumericRangeFilter(field_name="tonnage", label="tonnage_Range")
    tonnage_null = filters.BooleanFilter(field_name="tonnage", label="Is tonnage Null", lookup_expr="isnull")

    no_of_vehicles = filters.NumberFilter(field_name="no_of_vehicles", label="no_of_vehicles")
    no_of_vehicles_range = filters.NumericRangeFilter(field_name="no_of_vehicles", label="no_of_vehicles_Range")
    no_of_vehicles_null = filters.BooleanFilter(field_name="no_of_vehicles", label="Is no_of_vehicles Null",
                                                lookup_expr="isnull")

    rate = filters.NumberFilter(field_name="rate", label="rate")
    rate_range = filters.NumericRangeFilter(field_name="rate", label="rate_Range")
    rate_null = filters.BooleanFilter(field_name="rate", label="Is rate Null", lookup_expr="isnull")

    material = filters.CharFilter(name="material", label="Material", lookup_expr='icontains')
    material_null = filters.BooleanFilter(name="material", label="Is Material Null",
                                          lookup_expr="isnull")

    type_of_vehicle = filters.CharFilter(name="type_of_vehicle__vehicle_type", label="Vehicle Type",
                                         lookup_expr='icontains')
    type_of_vehicle_null = filters.BooleanFilter(name="type_of_vehicle", label="Is Vehicle Type Null",
                                                 lookup_expr="isnull")

    status = filters.ChoiceFilter(name="req_status", label="Req Status", choices=REQ_STATUS)
    req_status_null = filters.BooleanFilter(name="req_status", label="Is Req Status Null", lookup_expr="isnull")

    created_by = filters.CharFilter(name="created_by__username", label="Created By name", lookup_expr="icontains")
    created_by_null = filters.BooleanFilter(name="created_by", label="Is Created By Null", lookup_expr="isnull")
    created_on = filters.IsoDateTimeFilter(name="created_on", label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(field_name="created_on", label="Created Between")

    class Meta:
        model = Requirement
        fields = []
Example #18
0
class OwnerVehicleFilter(filters.FilterSet):
    vehicle_status_choice = (('free', 'FREE'), ('in_transit', 'In Transit'),
                             ('to_pickup', 'TO be Pick Up'),
                             ('delivery', 'To be Delivered'))
    body_type_choice = (
        ('open', 'Open'),
        ('closed', 'Closed'),
        ('semi', 'Semi'),
        ('half', 'Half'),
        ('containerized', 'Containerized'),
    )
    id = filters.NumberFilter(name="id", label="ID", lookup_expr="exact")
    id_range = filters.RangeFilter(name="id", label="ID Between")

    owner = ListFilter(name="owner__id", label="Owner name")
    owner_null = filters.BooleanFilter(name="owner",
                                       label="Is Owner Null",
                                       lookup_expr="isnull")

    driver = ListFilter(name="driver__id", label="Driver name")
    driver_null = filters.BooleanFilter(name="driver",
                                        label="Is Driver Null",
                                        lookup_expr="isnull")

    vehicle_number = filters.CharFilter(name="vehicle_number",
                                        label="Vehicle Number",
                                        lookup_expr='icontains')

    route_source = filters.CharFilter(name="route__source__name",
                                      label="Route Source",
                                      lookup_expr='icontains')
    route_destination = filters.CharFilter(name="route__destination__name",
                                           label="Route Destination",
                                           lookup_expr='icontains')
    route_null = filters.BooleanFilter(name="route",
                                       label="Is Route Null",
                                       lookup_expr="isnull")

    rc_number = filters.CharFilter(name="rc_number",
                                   label="RC Number",
                                   lookup_expr='icontains')
    rc_number_null = filters.BooleanFilter(name="rc_number",
                                           label="Is RC Number Null",
                                           lookup_expr="isnull")

    permit = filters.CharFilter(name="permit",
                                label="Permit",
                                lookup_expr='icontains')
    permit_null = filters.BooleanFilter(name="permit",
                                        label="Is Permit Null",
                                        lookup_expr="isnull")

    permit_validity = filters.DateFilter(name="permit_validity",
                                         label="Permit Validity",
                                         lookup_expr='icontains')
    permit_validity_null = filters.BooleanFilter(
        name="permit_validity",
        label="Is Permit Validity Null",
        lookup_expr="isnull")

    permit_type = filters.CharFilter(name="permit_type",
                                     label="Permit Type",
                                     lookup_expr='icontains')
    permit_type_null = filters.BooleanFilter(name="permit_type",
                                             label="Is Permit Type Null",
                                             lookup_expr="isnull")

    vehicle_type = filters.NumberFilter(name="vehicle_type__id",
                                        label="Vehicle Type",
                                        lookup_expr='exact')
    vehicle_type_null = filters.BooleanFilter(name="vehicle_type",
                                              label="Is Vehicle Type Null",
                                              lookup_expr="isnull")

    vehicle_capacity = filters.NumberFilter(name="vehicle_capacity",
                                            label="vehicle Capacity",
                                            lookup_expr='icontains')
    vehicle_capacity_range = filters.NumericRangeFilter(
        name="vehicle_capacity", label="vehicle Capacity")

    body_type = filters.ChoiceFilter(name="body_type",
                                     label="Body Type",
                                     choices=body_type_choice)

    body_type_null = filters.BooleanFilter(name="body_type",
                                           label="Is Body Type Null",
                                           lookup_expr="isnull")

    vehicle_model = filters.CharFilter(name="vehicle_model",
                                       label="Vehicle Model",
                                       lookup_expr='icontains')
    chassis_number = filters.CharFilter(name="chassis_number",
                                        label="Chasis Number",
                                        lookup_expr='icontains')
    chassis_number_null = filters.BooleanFilter(name="chassis_number",
                                                label="Is Chasis Number Null",
                                                lookup_expr="isnull")
    engine_number = filters.CharFilter(name="engine_number",
                                       label="Engine Number",
                                       lookup_expr='icontains')
    engine_number_null = filters.BooleanFilter(name="engine_number",
                                               label="Is Engine Number Null",
                                               lookup_expr="isnull")

    insurer = filters.CharFilter(name="insurer",
                                 label="Insurer",
                                 lookup_expr='icontains')
    insurance_number = filters.CharFilter(name="insurance_number",
                                          label="Insurance Number",
                                          lookup_expr='icontains')

    insurance_validity = filters.DateFilter(name="insurance_validity",
                                            label="Insurance Validity",
                                            lookup_expr='icontains')
    insurance_validity_null = filters.BooleanFilter(
        name="insurance_validity",
        label="Is Insurance Validity Null",
        lookup_expr="isnull")
    registration_year = filters.DateFilter(name="registration_year",
                                           label="Registration year",
                                           lookup_expr='icontains')
    registration_year_null = filters.BooleanFilter(
        name="registration_year",
        label="Is Registration Year Null",
        lookup_expr="isnull")
    registration_year_range = filters.DateFromToRangeFilter(
        name="registration_year", label="Registration Year range")

    registration_validity = filters.DateFilter(name="registration_validity",
                                               label="Registration Validity",
                                               lookup_expr='icontains')
    registration_validity_range = filters.DateFromToRangeFilter(
        name="registration_validity", label="Registration Validity Range")

    fitness_certificate_number = filters.CharFilter(
        name="fitness_certificate_number",
        label="Fitness Certificate Number",
        lookup_expr='icontains')
    fitness_certificate_number_null = filters.BooleanFilter(
        name="fitness_certificate_number",
        label="Is Fitness Certificate Number Null",
        lookup_expr="isnull")

    fitness_certificate_issued_on = filters.DateFilter(
        name="fitness_certificate_issued_on",
        label="Fitness Certificate issued on",
        lookup_expr='icontains')
    fitness_certificate_issued_on_range = filters.DateFromToRangeFilter(
        name="fitness_certificate_issued_on",
        label="Fitness Certificate issued on Range")

    puc_certificate_number = filters.CharFilter(
        name="puc_certificate_number",
        label="PUC Certificate Number Null",
        lookup_expr='icontains')
    puc_certificate_number_null = filters.BooleanFilter(
        name="puc_certificate_number",
        label="Is PUC Certificate Number Null",
        lookup_expr="isnull")

    puc_certificate_issued_on = filters.DateFilter(
        name="puc_certificate_issued_on",
        label="PUC Certificate issued on",
        lookup_expr='icontains')
    puc_certificate_issued_on_range = filters.DateFromToRangeFilter(
        name="puc_certificate_issued_on",
        label="PUC Certificate issued on Range")

    status = filters.ChoiceFilter(name="status",
                                  label="Status",
                                  choices=vehicle_status_choice)

    status_null = filters.BooleanFilter(name="status",
                                        label="Is Status Null",
                                        lookup_expr="isnull")

    gps_enabled = filters.BooleanFilter(name="gps_enabled",
                                        label="Is GPS Enable",
                                        lookup_expr="exact")

    created_by = filters.CharFilter(name="created_by__username",
                                    label="Created By name",
                                    lookup_expr="icontains")
    created_by_null = filters.BooleanFilter(name="created_by",
                                            label="Is Created By Null",
                                            lookup_expr="isnull")

    created_on = filters.IsoDateTimeFilter(name="created_on",
                                           label="Created on")
    created_between = filters.DateTimeFromToRangeFilter(
        name="created_on", label="Created Between")

    # Reverse relations
    serial = filters.CharFilter(name="vehicle_files__serial",
                                label="Vehicle Files Serial",
                                lookup_expr="icontains")
    verified = filters.BooleanFilter(name="vehicle_files__verified",
                                     label="Vehicle Files Verified",
                                     lookup_expr="exact")

    class Meta:
        model = Vehicle
        fields = []