geonode.base.models

Attributes

logger

Classes

ContactRole

ContactRole is an intermediate model to bind Profiles as Contacts to Resources and apply roles.

TopicCategory

Metadata about high-level geographic data thematic classification.

SpatialRepresentationType

Metadata information about the spatial representation type.

Region

Save bbox values in the database.

RestrictionCodeType

Metadata information about the spatial representation type.

License

HierarchicalKeywordQuerySet

QuerySet to automatically create a root node if depth not given.

HierarchicalKeywordManager

HierarchicalKeyword

TaggedContentItem

_HierarchicalTagManager

Thesaurus

Loadable thesaurus containing keywords in different languages

ThesaurusKeywordLabel

Loadable thesaurus containing keywords in different languages

ThesaurusKeyword

Loadable thesaurus containing keywords in different languages

ThesaurusLabel

Contains localized version of the thesaurus title

ResourceBaseManager

ResourceBase

Base Resource Object loosely based on ISO 19115:2003

LinkManager

Helper class to access links grouped by type

LinkedResource

Link

Auxiliary model for storing links for resources.

MenuPlaceholder

Menu

MenuItem

Configuration

A model used for managing the Geonode instance's global configuration, without a need for reloading the instance.

UserGeoLimit

GroupGeoLimit

ExtraMetadata

Functions

generate_thesaurus_reference(instance, *args, **kwargs)

rating_post_save(instance, *args, **kwargs)

Used to fill the average rating field on OverallRating change.

Module Contents

geonode.base.models.logger[source]
class geonode.base.models.ContactRole[source]

Bases: django.db.models.Model

ContactRole is an intermediate model to bind Profiles as Contacts to Resources and apply roles.

resource[source]
contact[source]
role[source]
class Meta[source]
unique_together = (('contact', 'resource', 'role'),)[source]
class geonode.base.models.TopicCategory[source]

Bases: django.db.models.Model

Metadata about high-level geographic data thematic classification.

It should reflect a list of codes from TC211

See: http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml

<CodeListDictionary gml:id=”MD_MD_TopicCategoryCode”>

identifier[source]
description[source]
gn_description[source]
is_choice[source]
fa_class[source]
__str__()[source]
class Meta[source]
ordering = ('identifier',)[source]
verbose_name_plural = 'Metadata Topic Categories'[source]
class geonode.base.models.SpatialRepresentationType[source]

Bases: django.db.models.Model

Metadata information about the spatial representation type.

It should reflect a list of codes from TC211

See: http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml

<CodeListDictionary gml:id=”MD_SpatialRepresentationTypeCode”>

identifier[source]
description[source]
gn_description[source]
is_choice[source]
__str__()[source]
class Meta[source]
ordering = ('identifier',)[source]
verbose_name_plural = 'Metadata Spatial Representation Types'[source]
class geonode.base.models.Region[source]

Bases: mptt.models.MPTTModel

Save bbox values in the database.

This is useful for spatial searches and for generating thumbnail images and metadata records.

code[source]
name[source]
parent[source]
bbox_x0[source]
bbox_x1[source]
bbox_y0[source]
bbox_y1[source]
srid[source]
__str__()[source]
property bbox[source]
BBOX is in the format:
[x0,x1,y0,y1]
property bbox_string[source]
BBOX is in the format:
[x0,y0,x1,y1]
property geographic_bounding_box[source]
BBOX is in the format:
[x0,x1,y0,y1]
property geom[source]
is_assignable_to_geom(extent_geom: django.contrib.gis.geos.GEOSGeometry)[source]
class Meta[source]
ordering = ('name',)[source]
verbose_name_plural = 'Metadata Regions'[source]
class MPTTMeta[source]
order_insertion_by = ['name'][source]
class geonode.base.models.RestrictionCodeType[source]

Bases: django.db.models.Model

Metadata information about the spatial representation type. It should reflect a list of codes from TC211

See: http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml

<CodeListDictionary gml:id=”MD_RestrictionCode”>

identifier[source]
description[source]
gn_description[source]
is_choice[source]
__str__()[source]
class Meta[source]
ordering = ('identifier',)[source]
verbose_name_plural = 'Metadata Restriction Code Types'[source]
class geonode.base.models.License[source]

Bases: django.db.models.Model

identifier[source]
name[source]
abbreviation[source]
description[source]
url[source]
license_text[source]
__str__()[source]
property name_long[source]
property description_bullets[source]
class Meta[source]
ordering = ('name',)[source]
verbose_name_plural = 'Licenses'[source]
class geonode.base.models.HierarchicalKeywordQuerySet[source]

Bases: treebeard.mp_tree.MP_NodeQuerySet

QuerySet to automatically create a root node if depth not given.

create(**kwargs)[source]
class geonode.base.models.HierarchicalKeywordManager[source]

Bases: treebeard.mp_tree.MP_NodeManager

get_queryset()[source]
class geonode.base.models.HierarchicalKeyword[source]

Bases: taggit.models.TagBase, treebeard.mp_tree.MP_Node

node_order_by = ['name'][source]
objects[source]
classmethod resource_keywords_tree(user, parent=None, resource_type=None, resource_name=None)[source]

Returns resource keywords tree as a dict object.

classmethod _keywords_tree_of_a_child(child, tree, newobj)[source]
class geonode.base.models.TaggedContentItem[source]

Bases: taggit.models.ItemBase

content_object[source]
tag[source]
classmethod tags_for(model, instance=None, **extra_filters)[source]
class geonode.base.models._HierarchicalTagManager[source]

Bases: taggit.managers._TaggableManager

add(*tags, through_defaults=None, tag_kwargs=None)[source]

If str_tags has 0 elements Django actually optimizes that to not do a query. Malcolm is very smart.

class geonode.base.models.Thesaurus[source]

Bases: django.db.models.Model

Loadable thesaurus containing keywords in different languages

id[source]
identifier[source]
title[source]
date[source]
description[source]
slug[source]
about[source]
card_min[source]
card_max[source]
facet[source]
order[source]
__str__()[source]
class Meta[source]
ordering = ('identifier',)[source]
verbose_name_plural = 'Thesauri'[source]
class geonode.base.models.ThesaurusKeywordLabel[source]

Bases: django.db.models.Model

Loadable thesaurus containing keywords in different languages

lang[source]
label[source]
keyword[source]
__str__()[source]
class Meta[source]
ordering = ('keyword', 'lang')[source]
verbose_name_plural = 'Thesaurus Keyword Labels'[source]
unique_together = (('keyword', 'lang'),)[source]
class geonode.base.models.ThesaurusKeyword[source]

Bases: django.db.models.Model

Loadable thesaurus containing keywords in different languages

about[source]
alt_label[source]
thesaurus[source]
image[source]
__str__()[source]
property labels[source]
class Meta[source]
ordering = ('alt_label',)[source]
verbose_name_plural = 'Thesaurus Keywords'[source]
unique_together = (('thesaurus', 'alt_label'),)[source]
geonode.base.models.generate_thesaurus_reference(instance, *args, **kwargs)[source]
class geonode.base.models.ThesaurusLabel[source]

Bases: django.db.models.Model

Contains localized version of the thesaurus title

lang[source]
label[source]
thesaurus[source]
__str__()[source]
class Meta[source]
ordering = ('lang',)[source]
verbose_name_plural = 'Thesaurus Labels'[source]
unique_together = (('thesaurus', 'lang'),)[source]
class geonode.base.models.ResourceBaseManager[source]

Bases: polymorphic.managers.PolymorphicManager

admin_contact()[source]
get_queryset()[source]
polymorphic_queryset()[source]
static upload_files(resource_id, files, force=False)[source]

Update the ResourceBase model

static cleanup_uploaded_files(resource_id)[source]

Remove uploaded files, if any

class geonode.base.models.ResourceBase(*args, **kwargs)[source]

Bases: polymorphic.models.PolymorphicModel, geonode.security.models.PermissionLevelMixin, taggit.models.ItemBase

Base Resource Object loosely based on ISO 19115:2003

BASE_PERMISSIONS[source]
PERMISSIONS[source]
VALID_DATE_TYPES[source]
abstract_help_text[source]
date_help_text[source]
date_type_help_text[source]
edition_help_text[source]
attribution_help_text[source]
doi_help_text[source]
purpose_help_text[source]
maintenance_frequency_help_text[source]
keywords_help_text[source]
tkeywords_help_text[source]
regions_help_text[source]
restriction_code_type_help_text[source]
constraints_other_help_text[source]
license_help_text[source]
language_help_text[source]
category_help_text[source]
spatial_representation_type_help_text[source]
temporal_extent_start_help_text[source]
temporal_extent_end_help_text[source]
data_quality_statement_help_text[source]
extra_metadata_help_text[source]
uuid[source]
title[source]
abstract[source]
purpose[source]
owner[source]
contacts[source]
alternate[source]
date[source]
date_type[source]
edition[source]
attribution[source]
doi[source]
maintenance_frequency[source]
keywords[source]
tkeywords[source]
regions[source]
restriction_code_type[source]
constraints_other[source]
license[source]
language[source]
category[source]
spatial_representation_type[source]
temporal_extent_start[source]
temporal_extent_end[source]
supplemental_information[source]
data_quality_statement[source]
group[source]
bbox_polygon[source]
ll_bbox_polygon[source]
srid[source]
csw_typename[source]
csw_schema[source]
csw_mdsource[source]
csw_insert_date[source]
csw_type[source]
csw_anytext[source]
csw_wkt_geometry[source]
metadata_uploaded[source]
metadata_uploaded_preserve[source]
metadata_xml[source]
popular_count[source]
share_count[source]
featured[source]
was_published[source]
is_published[source]
was_approved[source]
is_approved[source]
thumbnail_url[source]
thumbnail_path[source]
rating[source]
created[source]
last_updated[source]
state[source]
sourcetype[source]
remote_typename[source]
dirty_state[source]
users_geolimits[source]
groups_geolimits[source]
resource_type[source]
metadata_only[source]
files[source]
blob[source]
subtype[source]
metadata[source]
objects[source]
class Meta[source]
permissions = (('change_resourcebase_permissions', 'Can change resource permissions'),...[source]
__str__()[source]
_remove_html_tags(attribute_str)[source]
allowed_permissions()[source]
compact_permission_labels()[source]
property raw_abstract[source]
property raw_purpose[source]
property raw_constraints_other[source]
property raw_supplemental_information[source]
property raw_data_quality_statement[source]
property detail_url[source]
clean()[source]
save(notify=False, *args, **kwargs)[source]

Send a notification when a resource is created or updated

delete(notify=True, *args, **kwargs)[source]

Send a notification when a layer, map or document is deleted

abstract get_upload_session()[source]
property site_url[source]
property creator[source]
property perms[source]
property organizationname[source]
property restriction_code[source]
property topiccategory[source]
property csw_crs[source]
property group_name[source]
property bbox[source]
BBOX is in the format:
[x0, x1, y0, y1, srid]
property ll_bbox[source]
BBOX is in the format
[x0, x1, y0, y1, "EPSG:srid"]

Provides backwards compatibility after transition to polygons.

property ll_bbox_string[source]
WGS84 BBOX is in the format:
[x0,y0,x1,y1]
property bbox_string[source]
BBOX is in the format:
[x0, y0, x1, y1]

Provides backwards compatibility after transition to polygons.

property bbox_helper[source]
bbox_x0()[source]
bbox_x1()[source]
bbox_y0()[source]
bbox_y1()[source]
property geographic_bounding_box[source]
Returns an EWKT representation of the bounding box in EPSG 4326
property license_light[source]
property license_verbose[source]
property metadata_completeness[source]
property instance_is_processed[source]
property is_copyable[source]
keyword_list()[source]
keyword_slug_list()[source]
region_name_list()[source]
spatial_representation_type_string()[source]
set_dirty_state()[source]
clear_dirty_state()[source]
set_processing_state(state)[source]
property processed[source]
property keyword_csv[source]
get_absolute_url()[source]
set_bbox_polygon(bbox, srid)[source]

Set bbox_polygon from bbox values.

Parameters:
  • bbox – list or tuple formatted as [xmin, ymin, xmax, ymax]

  • srid – srid as string (e.g. ‘EPSG:4326’ or ‘4326’)

set_ll_bbox_polygon(bbox, srid='EPSG:4326')[source]

Set ll_bbox_polygon from bbox values.

Parameters:
  • bbox – list or tuple formatted as [xmin, ymin, xmax, ymax]

  • srid – srid as string (e.g. ‘EPSG:4326’ or ‘4326’)

set_bounds_from_bbox(bbox, srid)[source]

Calculate zoom level and center coordinates in mercator.

Parameters:

bbox (list) –

BBOX is either a geos.Pologyon or in the format: [x0, x1, y0, y1], which is:

[min lon, max lon, min lat, max lat]

or

[xmin, xmax, ymin, ymax]

set_center_zoom()[source]

Sets the center coordinates and zoom level in EPSG:4326

Assemble download links for pycsw

property embed_url[source]
get_tiles_url()[source]

Return URL for Z/Y/X mapping clients or None if it does not exist.

get_legend()[source]

Return Link for legend or None if it does not exist.

get_legend_url(style_name=None)[source]

Return URL for legend or None if it does not exist.

The legend can be either an image (for Geoserver’s WMS) or a JSON object for ArcGIS.

get_ows_url()[source]

Return URL for OGC WMS server None if it does not exist.

get_thumbnail_url()[source]

Return a thumbnail url.

It could be a local one if it exists, a remote one (WMS GetImage) for example

has_thumbnail()[source]

Determine if the thumbnail object exists and an image exists

save_thumbnail(filename, image, **kwargs)[source]
set_missing_info()[source]

Set default permissions and point of contacts.

It is mandatory to call it from descendant classes but hard to enforce technically via signals or save overriding.

maintenance_frequency_title()[source]
language_title()[source]
add_missing_metadata_author_or_poc()[source]

Set metadata_author and/or point of contact (poc) to a resource when any of them is missing

static get_multivalue_role_property_names() List[str][source]

Returns list of property names for all contact roles able to handle multiple profile_users

Returns:

list of names

Return type:

list[str]

static get_multivalue_required_role_property_names() List[str][source]

Returns list of property names for all contact roles that are required

Returns:

list of names

Return type:

list[str]

static get_ui_toggled_role_property_names() List[str][source]

Returns list of property names for all contact roles that are toggled of in metadata_editor

Returns:

list of names

Return type:

list[str]

set_contact_roles_from_metadata_edit(resource_base_form) bool[source]

Gets a ResourceBaseForm and extracts the Contact Role elements from it

Parameters:

resource_base_form (ResourceBaseForm) – ResourceBaseForm with contact roles set

Returns:

True if all contact roles could be set, else False.

Return type:

bool

__get_contact_role_elements__(role: str) List[django.conf.settings.AUTH_USER_MODEL] | None[source]

General getter of for all contact roles except owner

Parameters:

role (str) – String corresponding to ROLE_VALUES in geonode/people/enumerations, defining which property is requested.

Returns:

The requested contact role from the database or None if not found.

Return type:

Optional[List[settings.AUTH_USER_MODEL]]

CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES[source]
__set_contact_role_element__(user_profile: CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES, role: str)[source]

General setter for all contact roles except owner in resource base.

Parameters:
  • user_profile (CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES) – The user profile to be set, must be one of the allowed types in CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES.

  • role (str) – String corresponding to ROLE_VALUES in geonode/people/enumerations, defining which property is to be set.

get_defined_multivalue_contact_roles() List[Tuple[List[django.conf.settings.AUTH_USER_MODEL], str]][source]

Returns all set contact roles of the resource with additional ROLE_VALUES from geonode.people.enumerations.ROLE_VALUES. Mainly used to simplify the generation of output XML.

Returns:

A list of tuples, where each tuple contains: 1. A list of people who have a certain role. 2. The role label.

Return type:

List[Tuple[List[people object], str]]

get_first_contact_of_role(role: str) ContactRole | None[source]

Get the first contact from the specified role.

Parameters:

role (str) – The role of the contact.

Returns:

The first contact with the specified role, or None if not found.

Return type:

Optional[ContactRole]

__get_poc__() List[django.conf.settings.AUTH_USER_MODEL][source]
__set_poc__(user_profile)[source]
poc[source]
property poc_csv[source]
_get_metadata_author()[source]

Contact Role: metadata_author

_set_metadata_author(user_profile)[source]
metadata_author[source]
property metadata_author_csv[source]
_get_processor()[source]

Contact Role: PROCESSOR

_set_processor(user_profile)[source]
processor[source]
property processor_csv[source]
_get_publisher()[source]

Contact Role: PUBLISHER

_set_publisher(user_profile)[source]
publisher[source]
property publisher_csv[source]
_get_custodian()[source]

Contact Role: CUSTODIAN

_set_custodian(user_profile)[source]
custodian[source]
property custodian_csv[source]
_get_distributor()[source]

Contact Role: DISTRIBUTOR

_set_distributor(user_profile)[source]
distributor[source]
property distributor_csv[source]
_get_resource_user()[source]

Contact Role: RESOURCE_USER

_set_resource_user(user_profile)[source]
resource_user[source]
property resource_user_csv[source]
_get_resource_provider()[source]

Contact Role: RESOURCE_PROVIDER

_set_resource_provider(user_profile)[source]
resource_provider[source]
property resource_provider_csv[source]
_get_originator()[source]

Contact Role: ORIGINATOR

_set_originator(user_profile)[source]
originator[source]
property originator_csv[source]
_get_principal_investigator()[source]

Contact Role: PRINCIPAL_INVESTIGATOR

_set_principal_investigator(user_profile)[source]
principal_investigator[source]
property principal_investigator_csv[source]
get_linked_resources(as_target: bool = False)[source]

Get all the linked resources to this ResourceBase instance. This is implemented as a method so that derived classes can override it (for instance, Maps may add related datasets)

class geonode.base.models.LinkManager[source]

Bases: django.db.models.Manager

Helper class to access links grouped by type

data()[source]
image()[source]
download()[source]
metadata()[source]
original()[source]
ows()[source]
class geonode.base.models.LinkedResource[source]

Bases: django.db.models.Model

source[source]
target[source]
internal[source]
classmethod get_linked_resources(source: ResourceBase = None, target: ResourceBase = None, is_internal: bool = None)[source]
classmethod get_target_ids(source: ResourceBase, is_internal: bool = None)[source]
classmethod get_targets(source: ResourceBase, is_internal: bool = None)[source]
classmethod resolve_targets(linked_resources)[source]
classmethod resolve_sources(linked_resources)[source]

Bases: django.db.models.Model

Auxiliary model for storing links for resources.

This helps avoiding the need for runtime lookups to the OWS server or the CSW Catalogue.

There are four types of links:

  • original: For uploaded files (Shapefiles or GeoTIFFs)

  • data: For WFS and WCS links that allow access to raw data

  • image: For WMS and TMS links

  • metadata: For CSW links

  • OGC:WMS: for WMS service links

  • OGC:WFS: for WFS service links

  • OGC:WCS: for WCS service links

resource[source]
extension[source]
name[source]
mime[source]
url[source]
objects[source]
__str__()[source]
class geonode.base.models.MenuPlaceholder[source]

Bases: django.db.models.Model

name[source]
__str__()[source]
class geonode.base.models.Menu[source]

Bases: django.db.models.Model

title[source]
placeholder[source]
order[source]
__str__()[source]
class Meta[source]
unique_together = (('placeholder', 'order'), ('placeholder', 'title'))[source]
ordering = ['order'][source]
class geonode.base.models.MenuItem[source]

Bases: django.db.models.Model

title[source]
menu[source]
order[source]
blank_target[source]
url[source]
__eq__(other)[source]
__ne__(other)[source]
__lt__(other)[source]
__le__(other)[source]
__gt__(other)[source]
__ge__(other)[source]
__hash__()[source]
__str__()[source]
class Meta[source]
unique_together = (('menu', 'order'), ('menu', 'title'))[source]
ordering = ['order'][source]
class geonode.base.models.Configuration[source]

Bases: geonode.singleton.SingletonModel

A model used for managing the Geonode instance’s global configuration, without a need for reloading the instance.

Usage: from geonode.base.models import Configuration

config = Configuration.load()

read_only[source]
maintenance[source]
class Meta[source]
verbose_name_plural = 'Configuration'[source]
__str__()[source]
class geonode.base.models.UserGeoLimit[source]

Bases: django.db.models.Model

user[source]
resource[source]
wkt[source]
class geonode.base.models.GroupGeoLimit[source]

Bases: django.db.models.Model

group[source]
resource[source]
wkt[source]
geonode.base.models.rating_post_save(instance, *args, **kwargs)[source]

Used to fill the average rating field on OverallRating change.

class geonode.base.models.ExtraMetadata[source]

Bases: django.db.models.Model

resource[source]
metadata[source]