Skip to content

filters

sensor.filters ¤

Classes¤

FilterVisible(target, model, field=None) ¤

Filter objects the user has permission to view.

Standard filter shows ALL objects available in the database when faced with a ForeignKey field. This filter shows only the objects that appear in the target model objects that the user has permission to view.

If field is None, the name of the model model is used.

Parameters:

Name Type Description Default
target type[Model]

Model containing the objects.

required
model type[Model]

Model of the objects to display.

required
field str | None

Field to filter by. Defaults to None.

None
Source code in management\filters.py
22
23
24
25
26
27
28
def __init__(
    self, target: type[Model], model: type[Model], field: str | None = None
) -> None:
    self.target = target
    self.model = model
    self.field = field or model.__name__.lower()
    self.permission = f"{target._meta.app_label}.view_{target._meta.model_name}"

Sensor ¤

Bases: PermissionsBase

Specific sensor details.

Attributes:

Name Type Description
sensor_id int

Primary key, sensor id.

code

(str) sensor code.

sensor_type SensorType

sensor type.

sensor_brand SensorBrand

sensor brand.

model str

specific model of the sensor.

serial str

serial number of the sensor.

status bool

sensor status.

Functions¤
__str__() ¤

Return the sensor code.

Source code in sensor\models.py
112
113
114
def __str__(self) -> str:
    """Return the sensor code."""
    return str(self.code)
get_absolute_url() ¤

Return the absolute url of the sensor.

Source code in sensor\models.py
116
117
118
def get_absolute_url(self) -> str:
    """Return the absolute url of the sensor."""
    return reverse("sensor:sensor_detail", kwargs={"pk": self.pk})

SensorBrand ¤

Bases: PermissionsBase

Brand of the sensor, eg. Davis, Texas Electronics, etc.

Attributes:

Name Type Description
brand_id

int, primary key, sensor brand id.

name

str, sensor brand name.

Functions¤
__str__() ¤

Return the brand name.

Source code in sensor\models.py
52
53
54
def __str__(self) -> str:
    """Return the brand name."""
    return str(self.name)
get_absolute_url() ¤

Return the absolute url of the sensor brand.

Source code in sensor\models.py
56
57
58
def get_absolute_url(self) -> str:
    """Return the absolute url of the sensor brand."""
    return reverse("sensor:sensorbrand_detail", kwargs={"pk": self.pk})

SensorFilter ¤

Bases: FilterSet

SensorType ¤

Bases: PermissionsBase

Type of sensor, eg. pluviometric, wind sensor, etc.

Attributes:

Name Type Description
sensor_type_id

int, primary key, sensor type id.

name

str, sensor type name.

Functions¤
__str__() ¤

Return the sensor type name.

Source code in sensor\models.py
32
33
34
def __str__(self) -> str:
    """Return the sensor type name."""
    return str(self.name)
get_absolute_url() ¤

Return the absolute url of the sensor type.

Source code in sensor\models.py
36
37
38
def get_absolute_url(self) -> str:
    """Return the absolute url of the sensor type."""
    return reverse("sensor:sensortype_detail", kwargs={"pk": self.pk})