admin
station.admin
¤
Classes¤
Basin
¤
Bases: PermissionsBase
River(s) basin where the station is located e.g. El Carmen.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the basin, e.g. El Carmen. |
image |
ImageField
|
Photography/Map of the basin. |
file |
FileField
|
PDF file with details of the basin. |
Functions¤
__str__()
¤
Return the basin name.
Source code in station/models.py
228 229 230 |
|
get_absolute_url()
¤
Return the absolute url of the basin.
Source code in station/models.py
232 233 234 |
|
BasinAdmin
¤
Country
¤
Bases: PermissionsBase
The country where a station or region is in.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Country name. |
Functions¤
__str__()
¤
Return the country name.
Source code in station/models.py
47 48 49 |
|
get_absolute_url()
¤
Return the absolute url of the country.
Source code in station/models.py
51 52 53 |
|
CountryAdmin
¤
Ecosystem
¤
Bases: PermissionsBase
The ecosystem associated with a station.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the ecosystem, e.g. rain forest. |
Functions¤
__str__()
¤
Return the ecosystem name.
Source code in station/models.py
107 108 109 |
|
get_absolute_url()
¤
Return the absolute url of the ecosystem.
Source code in station/models.py
111 112 113 |
|
EcosystemAdmin
¤
Institution
¤
Bases: PermissionsBase
Institutional partner responsible for a station.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the institution. |
Functions¤
__str__()
¤
Return the institution name.
Source code in station/models.py
130 131 132 |
|
get_absolute_url()
¤
Return the absolute url of the institution.
Source code in station/models.py
134 135 136 |
|
InstitutionAdmin
¤
PermissionsBaseAdmin
¤
Bases: GuardedModelAdmin
Base admin class for models that require permissions.
Functions¤
formfield_for_choice_field(db_field, request, **kwargs)
¤
Limit the queryset for choice fields.
Source code in management/admin.py
75 76 77 78 79 80 81 |
|
formfield_for_foreignkey(db_field, request, **kwargs)
¤
Limit the queryset for foreign key fields.
Source code in management/admin.py
66 67 68 69 70 71 72 73 |
|
get_queryset(request)
¤
Return a queryset of the objects that the user has view permissions for.
Source code in management/admin.py
59 60 61 62 63 64 |
|
has_change_permission(request, obj=None)
¤
Check if the user has the correct permission to change the object.
Source code in management/admin.py
23 24 25 26 27 28 29 |
|
has_delete_permission(request, obj=None)
¤
Check if the user has the correct permission to delete the object.
Source code in management/admin.py
31 32 33 34 35 |
|
has_view_permission(request, obj=None)
¤
Check if the user has the correct permission to view the object.
Source code in management/admin.py
37 38 39 40 41 42 |
|
obj_perms_manage_view(request, object_pk)
¤
Prevents permission scalation at object level.
Only allows users with change permissions for this object to change the object permissions.
Source code in management/admin.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
Place
¤
Bases: PermissionsBase
Specific place that a station is situated.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the place, e.g. Huaraz. |
image |
ImageField
|
Photography/Map of the location. |
Functions¤
__str__()
¤
Return the place name.
Source code in station/models.py
187 188 189 |
|
get_absolute_url()
¤
Return the absolute url of the place.
Source code in station/models.py
191 192 193 |
|
PlaceAdmin
¤
PlaceBasin
¤
Bases: PermissionsBase
Associates a Basin with a Place and an image.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
place |
Place
|
Place of the association. |
basin |
Basin
|
Basin of the association. |
image |
ImageField
|
Photography/Map of the place within the basin. |
Functions¤
__str__()
¤
Return the place-basin association.
Source code in station/models.py
273 274 275 |
|
get_absolute_url()
¤
Return the absolute url of the place-basin association.
Source code in station/models.py
277 278 279 |
|
PlaceBasinAdmin
¤
Region
¤
Bases: PermissionsBase
A region within a country.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the region. |
country |
Country
|
Country where the region is located. |
Functions¤
__str__()
¤
Return the region name.
Source code in station/models.py
82 83 84 |
|
get_absolute_url()
¤
Return the absolute url of the region.
Source code in station/models.py
86 87 88 |
|
RegionAdmin
¤
Station
¤
Bases: PermissionsBase
Main representation of a station, including several metadata.
Attributes:
Name | Type | Description |
---|---|---|
visibility |
str
|
Visibility level of the object, including an "internal" option. |
station_id |
int
|
Primary key. |
station_code |
str
|
Unique code for the station. |
station_name |
str
|
Brief description of the station. |
station_type |
StationType
|
Type of the station. |
country |
Country
|
Country where the station is located. |
region |
Region
|
Region within the Country where the station is located. |
ecosystem |
Ecosystem
|
Ecosystem associated with the station. |
institution |
Institution
|
Institutional partner responsible for the station. |
place_basin |
PlaceBasin
|
Place-Basin association. |
station_state |
bool
|
Is the station operational? |
timezone |
str
|
Timezone of the station. |
station_latitude |
Decimal
|
Latitude of the station, in degrees [-90 to 90]. |
station_longitude |
Decimal
|
Longitude of the station, in degrees [-180 to 180]. |
station_altitude |
int
|
Altitude of the station. |
influence_km |
Decimal
|
Area of influence in km2. |
station_file |
ImageField
|
Photography of the station. |
station_external |
bool
|
Is the station external? |
variables |
str
|
Comma-separated list of variables measured by the station. |
Attributes¤
variables_list: list[str]
property
¤
Return the list of variables measured by the station.
Only variables with data in the database are returned.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of variables measured by the station. |
Functions¤
__str__()
¤
Return the station code.
Source code in station/models.py
458 459 460 |
|
get_absolute_url()
¤
Return the absolute url of the station.
Source code in station/models.py
462 463 464 |
|
set_object_permissions()
¤
Set object-level permissions.
This method is called by the save method of the model to set the object-level permissions based on the visibility level of the object. In addition to the standard permissions for the station, the view_measurements permission is set which controls who can view the measurements associated to the station.
Source code in station/models.py
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
|
StationAdmin
¤
StationType
¤
Bases: PermissionsBase
Type of the station, indicating what it measures.
Attributes:
Name | Type | Description |
---|---|---|
id |
int
|
Primary key. |
name |
str
|
Name of the station type, e.g. pluvometric, hydrological. |
Functions¤
__str__()
¤
Return the station type name.
Source code in station/models.py
156 157 158 |
|
get_absolute_url()
¤
Return the absolute url of the station type.
Source code in station/models.py
160 161 162 |
|