"""
_____________________________________________________________________.

:PROJECT: LARAsuite

*lara_django_data filter app *

:details: lara_django_data filter app.
         -
:authors: mark doerr <mark.doerr@uni-greifswald.de>

.. note:: -
.. todo:: -
________________________________________________________________________
"""

from django_filters.rest_framework import FilterSet

from .models import (
    Device,
    DeviceSetup,
    DeviceSetupShape,
    DeviceShape,
    ExtraData,
    Labware,
    LabwareClass,
    LabwareShape,
    Part,
    PartDeviceClass,
    PartShape,
    WellShape,
)


class ExtraDataFilterSet(FilterSet):
    """ExtraDataFilterSet class."""

    class Meta:
        """Meta class."""

        model = ExtraData
        fields = {
            "name_display": ["exact", "contains"],
            "name": ["exact", "contains"],
            "iri": ["exact", "contains"],
            "url": ["exact", "contains"],
            "datetime_created": ["lt", "gt", "exact", "range"],
            "datetime_last_modified": ["lt", "gt", "exact", "range"],
            "description": ["exact", "contains"],
        }


class PartDeviceClassFilterSet(FilterSet):
    """PartDeviceClassFilterSet class."""

    class Meta:
        """Meta class."""

        model = PartDeviceClass
        fields = {
            "name": ["exact", "contains"],
            "description": ["exact", "contains"],
        }


class PartShapeFilterSet(FilterSet):
    """PartShapeFilterSet class."""

    class Meta:
        """Meta class."""

        model = PartShape
        fields = {
            "name": ["exact", "contains"],
            "description": ["exact", "contains"],
        }


class PartFilterSet(FilterSet):
    """PartFilterSet class."""

    model = Part
    fields = {
        "name": ["exact", "contains"],
        "name_display": ["exact", "contains"],
        "url": ["exact", "contains"],
        "pid": ["exact", "contains"],
        "iri": ["exact", "contains"],
        "model_no": ["exact", "contains"],
        "product_type": ["exact", "contains"],
        "type_barcode": ["exact", "contains"],
        "product_no": ["exact", "contains"],
        "weight": ["lt", "gt", "exact", "range"],
        "energy_consumption": ["lt", "gt", "exact", "range"],
        "datetime_last_modified": ["lt", "gt", "exact", "range"],
        "description": ["exact", "contains"],
    }


class DeviceShapeFilterSet(FilterSet):
    """DeviceShapeFilterSet class."""

    model = DeviceShape
    fields = {
        "name": ["exact", "contains"],
        "description": ["exact", "contains"],
    }


class DeviceFilterSet(FilterSet):
    """DeviceFilterSet class."""

    model = Device
    fields = {
        "name": ["exact", "contains"],
        "name_display": ["exact", "contains"],
        "manufacturer__name": ["exact", "contains"],
        "url": ["exact", "contains"],
        "pid": ["exact", "contains"],
        "iri": ["exact", "contains"],
        "model_no": ["exact", "contains"],
        "product_type": ["exact", "contains"],
        "type_barcode": ["exact", "contains"],
        "product_no": ["exact", "contains"],
        "weight": ["lt", "gt", "exact", "range"],
        "energy_consumption": ["lt", "gt", "exact", "range"],
        "datetime_last_modified": ["lt", "gt", "exact", "range"],
        "description": ["exact", "contains"],
        "labware_min_capacity": ["lt", "gt", "exact"],
        "labware_max_capacity": ["lt", "gt", "exact"],
        "labware_max_height": ["lt", "gt", "exact"],
    }


class DeviceSetupShapeFilterSet(FilterSet):
    """DeviceSetupShapeFilterSet class."""

    model = DeviceSetupShape
    fields = {
        "name": ["exact", "contains"],
        "description": ["exact", "contains"],
    }


class DeviceSetupFilterSet(FilterSet):
    """DeviceSetupFilterSet class."""

    model = DeviceSetup
    fields = {
        "name": ["exact", "contains"],
        "name_display": ["exact", "contains"],
        "manufacturer__name": ["exact", "contains"],
        "url": ["exact", "contains"],
        "pid": ["exact", "contains"],
        "iri": ["exact", "contains"],
        "model_no": ["exact", "contains"],
        "product_type": ["exact", "contains"],
        "type_barcode": ["exact", "contains"],
        "product_no": ["exact", "contains"],
        "weight": ["lt", "gt", "exact", "range"],
        "energy_consumption": ["lt", "gt", "exact", "range"],
        "datetime_last_modified": ["lt", "gt", "exact", "range"],
        "description": ["exact", "contains"],
    }


class LabwareClassFilterSet(FilterSet):
    """LabwareClassFilterSet class."""

    model = LabwareClass
    fields = {
        "name": ["exact", "contains"],
        "description": ["exact", "contains"],
    }


class WellShapeFilterSet(FilterSet):
    """WellShapeFilterSet class."""

    model = WellShape
    fields = {
        "name": ["exact", "contains"],
        "description": ["exact", "contains"],
    }


class LabwareShapeFilterSet(FilterSet):
    """LabwareShapeFilterSet class."""

    model = LabwareShape
    fields = {
        "name": ["exact", "contains"],
        "well_dist_row": ["lt", "gt", "exact"],
        "well_dist_col": ["lt", "gt", "exact"],
        "description": ["exact", "contains"],
    }


class LabwareFilterSet(FilterSet):
    """LabwareFilterSet class."""

    model = Labware
    fields = {
        "name": ["exact", "contains"],
        "name_display": ["exact", "contains"],
        "manufacturer__name": ["exact", "contains"],
        "url": ["exact", "contains"],
        "pid": ["exact", "contains"],
        "iri": ["exact", "contains"],
        "model_no": ["exact", "contains"],
        "product_type": ["exact", "contains"],
        "type_barcode": ["exact", "contains"],
        "product_no": ["exact", "contains"],
        "weight": ["lt", "gt", "exact", "range"],
        "energy_consumption": ["lt", "gt", "exact", "range"],
        "datetime_last_modified": ["lt", "gt", "exact", "range"],
        "description": ["exact", "contains"],
        "num_rows": ["lt", "gt", "exact"],
        "num_cols": ["lt", "gt", "exact"],
        "num_wells": ["lt", "gt", "exact"],
        #'labware_class': ['exact'],
    }
