admin
measurement.admin
¤
Classes¤
Measurement
¤
Bases: MeasurementBase
Class to store the measurements and their validation status.
This class holds the value of a given variable and station at a specific time, as
well as auxiliary information such as maximum and minimum values, depth and
direction, for vector quantities. All of these have a raw
version where a backup
of the original data is kept, should this change at any point.
Flags to monitor its validation status, if the data is active (and therefore can be used for reporting) and if it has actually been used for that is also included.
Attributes:
Name | Type | Description |
---|---|---|
depth |
int
|
Depth of the measurement. |
direction |
Decimal
|
Direction of the measurement, useful for vector quantities. |
raw_value |
Decimal
|
Original value of the measurement. |
raw_maximum |
Decimal
|
Original maximum value of the measurement. |
raw_minimum |
Decimal
|
Original minimum value of the measurement. |
raw_direction |
Decimal
|
Original direction of the measurement. |
raw_depth |
int
|
Original depth of the measurement. |
is_validated |
bool
|
Flag to indicate if the measurement has been validated. |
is_active |
bool
|
Flag to indicate if the measurement is active. An inactive measurement is not used for reporting |
Attributes¤
overwritten: bool
property
¤
Indicates if any of the values associated to the entry have been overwritten.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if any raw field is different to the corresponding standard field. |
raws: tuple[str, ...]
property
¤
Return the raw fields of the measurement.
Returns:
Type | Description |
---|---|
tuple[str, ...]
|
tuple[str]: Tuple with the names of the raw fields of the measurement. |
Functions¤
clean()
¤
Check consistency of validation, reporting and backs-up values.
Source code in measurement\models.py
259 260 261 262 263 264 265 266 267 268 269 |
|
MeasurementAdmin
¤
MeasurementBaseAdmin
¤
Bases: GuardedModelAdmin
Functions¤
formfield_for_foreignkey(db_field, request, **kwargs)
¤
Limit the queryset for foreign key fields.
Source code in measurement\admin.py
43 44 45 46 47 48 49 50 51 |
|
get_queryset(request)
¤
Return a queryset of the objects that the user has view permissions for.
Source code in measurement\admin.py
37 38 39 40 41 |
|
has_add_permission(request)
¤
Check if the user has the correct permission to add objects.
Source code in measurement\admin.py
13 14 15 16 17 |
|
has_change_permission(request, obj=None)
¤
Check if the user has the correct permission to change the object.
Source code in measurement\admin.py
19 20 21 22 23 |
|
has_delete_permission(request, obj=None)
¤
Check if the user has the correct permission to delete the object.
Source code in measurement\admin.py
25 26 27 28 29 |
|
has_view_permission(request, obj=None)
¤
Check if the user has the correct permission to view the object.
Source code in measurement\admin.py
31 32 33 34 35 |
|
Report
¤
Bases: MeasurementBase
Holds the different reporting data.
It also keeps track of which data has already been used when creating the reports.
Attributes:
Name | Type | Description |
---|---|---|
report_type |
str
|
Type of report. It can be hourly, daily or monthly. |
completeness |
Decimal
|
Completeness of the report. Eg. a daily report with 24 hourly measurements would have a completeness of 100%. |
Functions¤
clean()
¤
Validate that the report type and use of the data is consistent.
Source code in measurement\models.py
147 148 149 150 151 152 153 154 155 156 |
|
ReportAdmin
¤
Functions¤
get_queryset(db_field, user)
¤
Return a queryset based on the permissions of the user.
Returns queryset of public objects and objects that the user has change permisions
for. For the case of Station
objects, having the change
permission is
necessary to include the object in the queryset - being Public
is not enough.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_field |
Field
|
Field to filter. |
required |
user |
Model
|
User to check permissions for. |
required |
Returns:
Type | Description |
---|---|
QuerySet
|
model.QuerySet: Queryset of objects that the user has permissions for. |
Source code in management\permissions.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|