geonode.base.models =================== .. py:module:: geonode.base.models Attributes ---------- .. autoapisummary:: geonode.base.models.logger Classes ------- .. autoapisummary:: geonode.base.models.ContactRole geonode.base.models.TopicCategory geonode.base.models.SpatialRepresentationType geonode.base.models.Region geonode.base.models.RestrictionCodeType geonode.base.models.License geonode.base.models.HierarchicalKeywordQuerySet geonode.base.models.HierarchicalKeywordManager geonode.base.models.HierarchicalKeyword geonode.base.models.TaggedContentItem geonode.base.models._HierarchicalTagManager geonode.base.models.Thesaurus geonode.base.models.ThesaurusKeywordLabel geonode.base.models.ThesaurusKeyword geonode.base.models.ThesaurusLabel geonode.base.models.ResourceBaseManager geonode.base.models.ResourceBase geonode.base.models.LinkManager geonode.base.models.LinkedResource geonode.base.models.Link geonode.base.models.MenuPlaceholder geonode.base.models.Menu geonode.base.models.MenuItem geonode.base.models.Configuration geonode.base.models.UserGeoLimit geonode.base.models.GroupGeoLimit geonode.base.models.ExtraMetadata Functions --------- .. autoapisummary:: geonode.base.models.generate_thesaurus_reference geonode.base.models.rating_post_save Module Contents --------------- .. py:data:: logger .. py:class:: ContactRole Bases: :py:obj:`django.db.models.Model` ContactRole is an intermediate model to bind Profiles as Contacts to Resources and apply roles. .. py:attribute:: resource .. py:attribute:: contact .. py:attribute:: role .. py:class:: Meta .. py:attribute:: unique_together :value: (('contact', 'resource', 'role'),) .. py:class:: TopicCategory Bases: :py:obj:`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 .. py:attribute:: identifier .. py:attribute:: description .. py:attribute:: gn_description .. py:attribute:: is_choice .. py:attribute:: fa_class .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('identifier',) .. py:attribute:: verbose_name_plural :value: 'Metadata Topic Categories' .. py:class:: SpatialRepresentationType Bases: :py:obj:`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 .. py:attribute:: identifier .. py:attribute:: description .. py:attribute:: gn_description .. py:attribute:: is_choice .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('identifier',) .. py:attribute:: verbose_name_plural :value: 'Metadata Spatial Representation Types' .. py:class:: Region Bases: :py:obj:`mptt.models.MPTTModel` Save bbox values in the database. This is useful for spatial searches and for generating thumbnail images and metadata records. .. py:attribute:: code .. py:attribute:: name .. py:attribute:: parent .. py:attribute:: bbox_x0 .. py:attribute:: bbox_x1 .. py:attribute:: bbox_y0 .. py:attribute:: bbox_y1 .. py:attribute:: srid .. py:method:: __str__() .. py:property:: bbox BBOX is in the format: .. code-block:: none [x0,x1,y0,y1] .. py:property:: bbox_string BBOX is in the format: .. code-block:: none [x0,y0,x1,y1] .. py:property:: geographic_bounding_box BBOX is in the format: .. code-block:: none [x0,x1,y0,y1] .. py:property:: geom .. py:method:: is_assignable_to_geom(extent_geom: django.contrib.gis.geos.GEOSGeometry) .. py:class:: Meta .. py:attribute:: ordering :value: ('name',) .. py:attribute:: verbose_name_plural :value: 'Metadata Regions' .. py:class:: MPTTMeta .. py:attribute:: order_insertion_by :value: ['name'] .. py:class:: RestrictionCodeType Bases: :py:obj:`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 .. py:attribute:: identifier .. py:attribute:: description .. py:attribute:: gn_description .. py:attribute:: is_choice .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('identifier',) .. py:attribute:: verbose_name_plural :value: 'Metadata Restriction Code Types' .. py:class:: License Bases: :py:obj:`django.db.models.Model` .. py:attribute:: identifier .. py:attribute:: name .. py:attribute:: abbreviation .. py:attribute:: description .. py:attribute:: url .. py:attribute:: license_text .. py:method:: __str__() .. py:property:: name_long .. py:property:: description_bullets .. py:class:: Meta .. py:attribute:: ordering :value: ('name',) .. py:attribute:: verbose_name_plural :value: 'Licenses' .. py:class:: HierarchicalKeywordQuerySet Bases: :py:obj:`treebeard.mp_tree.MP_NodeQuerySet` QuerySet to automatically create a root node if `depth` not given. .. py:method:: create(**kwargs) .. py:class:: HierarchicalKeywordManager Bases: :py:obj:`treebeard.mp_tree.MP_NodeManager` .. py:method:: get_queryset() .. py:class:: HierarchicalKeyword Bases: :py:obj:`taggit.models.TagBase`, :py:obj:`treebeard.mp_tree.MP_Node` .. py:attribute:: node_order_by :value: ['name'] .. py:attribute:: objects .. py:method:: resource_keywords_tree(user, parent=None, resource_type=None, resource_name=None) :classmethod: Returns resource keywords tree as a dict object. .. py:method:: _keywords_tree_of_a_child(child, tree, newobj) :classmethod: .. py:class:: TaggedContentItem Bases: :py:obj:`taggit.models.ItemBase` .. py:attribute:: content_object .. py:attribute:: tag .. py:method:: tags_for(model, instance=None, **extra_filters) :classmethod: .. py:class:: _HierarchicalTagManager Bases: :py:obj:`taggit.managers._TaggableManager` .. py:method:: add(*tags, through_defaults=None, tag_kwargs=None) If str_tags has 0 elements Django actually optimizes that to not do a query. Malcolm is very smart. .. py:class:: Thesaurus Bases: :py:obj:`django.db.models.Model` Loadable thesaurus containing keywords in different languages .. py:attribute:: id .. py:attribute:: identifier .. py:attribute:: title .. py:attribute:: date .. py:attribute:: description .. py:attribute:: slug .. py:attribute:: about .. py:attribute:: card_min .. py:attribute:: card_max .. py:attribute:: facet .. py:attribute:: order .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('identifier',) .. py:attribute:: verbose_name_plural :value: 'Thesauri' .. py:class:: ThesaurusKeywordLabel Bases: :py:obj:`django.db.models.Model` Loadable thesaurus containing keywords in different languages .. py:attribute:: lang .. py:attribute:: label .. py:attribute:: keyword .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('keyword', 'lang') .. py:attribute:: verbose_name_plural :value: 'Thesaurus Keyword Labels' .. py:attribute:: unique_together :value: (('keyword', 'lang'),) .. py:class:: ThesaurusKeyword Bases: :py:obj:`django.db.models.Model` Loadable thesaurus containing keywords in different languages .. py:attribute:: about .. py:attribute:: alt_label .. py:attribute:: thesaurus .. py:attribute:: image .. py:method:: __str__() .. py:property:: labels .. py:class:: Meta .. py:attribute:: ordering :value: ('alt_label',) .. py:attribute:: verbose_name_plural :value: 'Thesaurus Keywords' .. py:attribute:: unique_together :value: (('thesaurus', 'alt_label'),) .. py:function:: generate_thesaurus_reference(instance, *args, **kwargs) .. py:class:: ThesaurusLabel Bases: :py:obj:`django.db.models.Model` Contains localized version of the thesaurus title .. py:attribute:: lang .. py:attribute:: label .. py:attribute:: thesaurus .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: ordering :value: ('lang',) .. py:attribute:: verbose_name_plural :value: 'Thesaurus Labels' .. py:attribute:: unique_together :value: (('thesaurus', 'lang'),) .. py:class:: ResourceBaseManager Bases: :py:obj:`polymorphic.managers.PolymorphicManager` .. py:method:: admin_contact() .. py:method:: get_queryset() .. py:method:: polymorphic_queryset() .. py:method:: upload_files(resource_id, files, force=False) :staticmethod: Update the ResourceBase model .. py:method:: cleanup_uploaded_files(resource_id) :staticmethod: Remove uploaded files, if any .. py:class:: ResourceBase(*args, **kwargs) Bases: :py:obj:`polymorphic.models.PolymorphicModel`, :py:obj:`geonode.security.models.PermissionLevelMixin`, :py:obj:`taggit.models.ItemBase` Base Resource Object loosely based on ISO 19115:2003 .. py:attribute:: BASE_PERMISSIONS .. py:attribute:: PERMISSIONS .. py:attribute:: VALID_DATE_TYPES .. py:attribute:: abstract_help_text .. py:attribute:: date_help_text .. py:attribute:: date_type_help_text .. py:attribute:: edition_help_text .. py:attribute:: attribution_help_text .. py:attribute:: doi_help_text .. py:attribute:: purpose_help_text .. py:attribute:: maintenance_frequency_help_text .. py:attribute:: keywords_help_text .. py:attribute:: tkeywords_help_text .. py:attribute:: regions_help_text .. py:attribute:: restriction_code_type_help_text .. py:attribute:: constraints_other_help_text .. py:attribute:: license_help_text .. py:attribute:: language_help_text .. py:attribute:: category_help_text .. py:attribute:: spatial_representation_type_help_text .. py:attribute:: temporal_extent_start_help_text .. py:attribute:: temporal_extent_end_help_text .. py:attribute:: data_quality_statement_help_text .. py:attribute:: extra_metadata_help_text .. py:attribute:: uuid .. py:attribute:: title .. py:attribute:: abstract .. py:attribute:: purpose .. py:attribute:: owner .. py:attribute:: contacts .. py:attribute:: alternate .. py:attribute:: date .. py:attribute:: date_type .. py:attribute:: edition .. py:attribute:: attribution .. py:attribute:: doi .. py:attribute:: maintenance_frequency .. py:attribute:: keywords .. py:attribute:: tkeywords .. py:attribute:: regions .. py:attribute:: restriction_code_type .. py:attribute:: constraints_other .. py:attribute:: license .. py:attribute:: language .. py:attribute:: category .. py:attribute:: spatial_representation_type .. py:attribute:: temporal_extent_start .. py:attribute:: temporal_extent_end .. py:attribute:: supplemental_information .. py:attribute:: data_quality_statement .. py:attribute:: group .. py:attribute:: bbox_polygon .. py:attribute:: ll_bbox_polygon .. py:attribute:: srid .. py:attribute:: csw_typename .. py:attribute:: csw_schema .. py:attribute:: csw_mdsource .. py:attribute:: csw_insert_date .. py:attribute:: csw_type .. py:attribute:: csw_anytext .. py:attribute:: csw_wkt_geometry .. py:attribute:: metadata_uploaded .. py:attribute:: metadata_uploaded_preserve .. py:attribute:: metadata_xml .. py:attribute:: popular_count .. py:attribute:: share_count .. py:attribute:: featured .. py:attribute:: was_published .. py:attribute:: is_published .. py:attribute:: was_approved .. py:attribute:: is_approved .. py:attribute:: thumbnail_url .. py:attribute:: thumbnail_path .. py:attribute:: rating .. py:attribute:: created .. py:attribute:: last_updated .. py:attribute:: state .. py:attribute:: sourcetype .. py:attribute:: remote_typename .. py:attribute:: dirty_state .. py:attribute:: users_geolimits .. py:attribute:: groups_geolimits .. py:attribute:: resource_type .. py:attribute:: metadata_only .. py:attribute:: files .. py:attribute:: blob .. py:attribute:: subtype .. py:attribute:: metadata .. py:attribute:: objects .. py:class:: Meta .. py:attribute:: permissions :value: (('change_resourcebase_permissions', 'Can change resource permissions'),... .. py:method:: __str__() .. py:method:: _remove_html_tags(attribute_str) .. py:method:: allowed_permissions() .. py:method:: compact_permission_labels() .. py:property:: raw_abstract .. py:property:: raw_purpose .. py:property:: raw_constraints_other .. py:property:: raw_supplemental_information .. py:property:: raw_data_quality_statement .. py:property:: detail_url .. py:method:: clean() .. py:method:: save(notify=False, *args, **kwargs) Send a notification when a resource is created or updated .. py:method:: delete(notify=True, *args, **kwargs) Send a notification when a layer, map or document is deleted .. py:method:: get_upload_session() :abstractmethod: .. py:property:: site_url .. py:property:: creator .. py:property:: perms .. py:property:: organizationname .. py:property:: restriction_code .. py:property:: topiccategory .. py:property:: csw_crs .. py:property:: group_name .. py:property:: bbox BBOX is in the format: .. code-block:: none [x0, x1, y0, y1, srid] .. py:property:: ll_bbox BBOX is in the format .. code-block:: none [x0, x1, y0, y1, "EPSG:srid"] Provides backwards compatibility after transition to polygons. .. py:property:: ll_bbox_string WGS84 BBOX is in the format: .. code-block:: none [x0,y0,x1,y1] .. py:property:: bbox_string BBOX is in the format: .. code-block:: none [x0, y0, x1, y1] Provides backwards compatibility after transition to polygons. .. py:property:: bbox_helper .. py:method:: bbox_x0() .. py:method:: bbox_x1() .. py:method:: bbox_y0() .. py:method:: bbox_y1() .. py:property:: geographic_bounding_box Returns an EWKT representation of the bounding box in EPSG 4326 .. py:property:: license_light .. py:property:: license_verbose .. py:property:: metadata_completeness .. py:property:: instance_is_processed .. py:property:: is_copyable .. py:method:: keyword_list() .. py:method:: keyword_slug_list() .. py:method:: region_name_list() .. py:method:: spatial_representation_type_string() .. py:method:: set_dirty_state() .. py:method:: clear_dirty_state() .. py:method:: set_processing_state(state) .. py:property:: processed .. py:property:: keyword_csv .. py:method:: get_absolute_url() .. py:method:: set_bbox_polygon(bbox, srid) Set `bbox_polygon` from bbox values. :param bbox: list or tuple formatted as [xmin, ymin, xmax, ymax] :param srid: srid as string (e.g. 'EPSG:4326' or '4326') .. py:method:: set_ll_bbox_polygon(bbox, srid='EPSG:4326') Set `ll_bbox_polygon` from bbox values. :param bbox: list or tuple formatted as [xmin, ymin, xmax, ymax] :param srid: srid as string (e.g. 'EPSG:4326' or '4326') .. py:method:: set_bounds_from_bbox(bbox, srid) Calculate zoom level and center coordinates in mercator. :param bbox: 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] :type bbox: list .. py:method:: set_center_zoom() Sets the center coordinates and zoom level in EPSG:4326 .. py:method:: download_links() Assemble download links for pycsw .. py:property:: embed_url .. py:method:: get_tiles_url() Return URL for Z/Y/X mapping clients or None if it does not exist. .. py:method:: get_legend() Return Link for legend or None if it does not exist. .. py:method:: get_legend_url(style_name=None) 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. .. py:method:: get_ows_url() Return URL for OGC WMS server None if it does not exist. .. py:method:: get_thumbnail_url() Return a thumbnail url. It could be a local one if it exists, a remote one (WMS GetImage) for example .. py:method:: has_thumbnail() Determine if the thumbnail object exists and an image exists .. py:method:: save_thumbnail(filename, image, **kwargs) .. py:method:: set_missing_info() 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. .. py:method:: maintenance_frequency_title() .. py:method:: language_title() .. py:method:: add_missing_metadata_author_or_poc() Set metadata_author and/or point of contact (poc) to a resource when any of them is missing .. py:method:: get_multivalue_role_property_names() -> List[str] :staticmethod: Returns list of property names for all contact roles able to handle multiple profile_users :returns: list of names :rtype: list[str] .. py:method:: get_multivalue_required_role_property_names() -> List[str] :staticmethod: Returns list of property names for all contact roles that are required :returns: list of names :rtype: list[str] .. py:method:: get_ui_toggled_role_property_names() -> List[str] :staticmethod: Returns list of property names for all contact roles that are toggled of in metadata_editor :returns: list of names :rtype: list[str] .. py:method:: set_contact_roles_from_metadata_edit(resource_base_form) -> bool Gets a ResourceBaseForm and extracts the Contact Role elements from it :param resource_base_form: ResourceBaseForm with contact roles set :type resource_base_form: ResourceBaseForm :returns: True if all contact roles could be set, else False. :rtype: bool .. py:method:: __get_contact_role_elements__(role: str) -> Optional[List[django.conf.settings.AUTH_USER_MODEL]] General getter of for all contact roles except owner :param role: String corresponding to `ROLE_VALUES` in `geonode/people/enumerations`, defining which property is requested. :type role: str :returns: The requested contact role from the database or None if not found. :rtype: Optional[List[settings.AUTH_USER_MODEL]] .. py:attribute:: CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES .. py:method:: __set_contact_role_element__(user_profile: CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES, role: str) General setter for all contact roles except owner in resource base. :param user_profile: The user profile to be set, must be one of the allowed types in `CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES`. :type user_profile: CONTACT_ROLE_USER_PROFILES_ALLOWED_TYPES :param role: String corresponding to `ROLE_VALUES` in `geonode/people/enumerations`, defining which property is to be set. :type role: str .. py:method:: get_defined_multivalue_contact_roles() -> List[Tuple[List[django.conf.settings.AUTH_USER_MODEL], str]] 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. :rtype: List[Tuple[List[people object], str]] .. py:method:: get_first_contact_of_role(role: str) -> Optional[ContactRole] Get the first contact from the specified role. :param role: The role of the contact. :type role: str :returns: The first contact with the specified role, or None if not found. :rtype: Optional[ContactRole] .. py:method:: __get_poc__() -> List[django.conf.settings.AUTH_USER_MODEL] .. py:method:: __set_poc__(user_profile) .. py:attribute:: poc .. py:property:: poc_csv .. py:method:: _get_metadata_author() Contact Role: metadata_author .. py:method:: _set_metadata_author(user_profile) .. py:attribute:: metadata_author .. py:property:: metadata_author_csv .. py:method:: _get_processor() Contact Role: PROCESSOR .. py:method:: _set_processor(user_profile) .. py:attribute:: processor .. py:property:: processor_csv .. py:method:: _get_publisher() Contact Role: PUBLISHER .. py:method:: _set_publisher(user_profile) .. py:attribute:: publisher .. py:property:: publisher_csv .. py:method:: _get_custodian() Contact Role: CUSTODIAN .. py:method:: _set_custodian(user_profile) .. py:attribute:: custodian .. py:property:: custodian_csv .. py:method:: _get_distributor() Contact Role: DISTRIBUTOR .. py:method:: _set_distributor(user_profile) .. py:attribute:: distributor .. py:property:: distributor_csv .. py:method:: _get_resource_user() Contact Role: RESOURCE_USER .. py:method:: _set_resource_user(user_profile) .. py:attribute:: resource_user .. py:property:: resource_user_csv .. py:method:: _get_resource_provider() Contact Role: RESOURCE_PROVIDER .. py:method:: _set_resource_provider(user_profile) .. py:attribute:: resource_provider .. py:property:: resource_provider_csv .. py:method:: _get_originator() Contact Role: ORIGINATOR .. py:method:: _set_originator(user_profile) .. py:attribute:: originator .. py:property:: originator_csv .. py:method:: _get_principal_investigator() Contact Role: PRINCIPAL_INVESTIGATOR .. py:method:: _set_principal_investigator(user_profile) .. py:attribute:: principal_investigator .. py:property:: principal_investigator_csv .. py:method:: get_linked_resources(as_target: bool = False) 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) .. py:class:: LinkManager Bases: :py:obj:`django.db.models.Manager` Helper class to access links grouped by type .. py:method:: data() .. py:method:: image() .. py:method:: download() .. py:method:: metadata() .. py:method:: original() .. py:method:: ows() .. py:class:: LinkedResource Bases: :py:obj:`django.db.models.Model` .. py:attribute:: source .. py:attribute:: target .. py:attribute:: internal .. py:method:: get_linked_resources(source: ResourceBase = None, target: ResourceBase = None, is_internal: bool = None) :classmethod: .. py:method:: get_target_ids(source: ResourceBase, is_internal: bool = None) :classmethod: .. py:method:: get_targets(source: ResourceBase, is_internal: bool = None) :classmethod: .. py:method:: resolve_targets(linked_resources) :classmethod: .. py:method:: resolve_sources(linked_resources) :classmethod: .. py:class:: Link Bases: :py:obj:`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 .. py:attribute:: resource .. py:attribute:: extension .. py:attribute:: link_type .. py:attribute:: name .. py:attribute:: mime .. py:attribute:: url .. py:attribute:: objects .. py:method:: __str__() .. py:class:: MenuPlaceholder Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:method:: __str__() .. py:class:: Menu Bases: :py:obj:`django.db.models.Model` .. py:attribute:: title .. py:attribute:: placeholder .. py:attribute:: order .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: unique_together :value: (('placeholder', 'order'), ('placeholder', 'title')) .. py:attribute:: ordering :value: ['order'] .. py:class:: MenuItem Bases: :py:obj:`django.db.models.Model` .. py:attribute:: title .. py:attribute:: menu .. py:attribute:: order .. py:attribute:: blank_target .. py:attribute:: url .. py:method:: __eq__(other) .. py:method:: __ne__(other) .. py:method:: __lt__(other) .. py:method:: __le__(other) .. py:method:: __gt__(other) .. py:method:: __ge__(other) .. py:method:: __hash__() .. py:method:: __str__() .. py:class:: Meta .. py:attribute:: unique_together :value: (('menu', 'order'), ('menu', 'title')) .. py:attribute:: ordering :value: ['order'] .. py:class:: Configuration Bases: :py:obj:`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() .. py:attribute:: read_only .. py:attribute:: maintenance .. py:class:: Meta .. py:attribute:: verbose_name_plural :value: 'Configuration' .. py:method:: __str__() .. py:class:: UserGeoLimit Bases: :py:obj:`django.db.models.Model` .. py:attribute:: user .. py:attribute:: resource .. py:attribute:: wkt .. py:class:: GroupGeoLimit Bases: :py:obj:`django.db.models.Model` .. py:attribute:: group .. py:attribute:: resource .. py:attribute:: wkt .. py:function:: rating_post_save(instance, *args, **kwargs) Used to fill the average rating field on OverallRating change. .. py:class:: ExtraMetadata Bases: :py:obj:`django.db.models.Model` .. py:attribute:: resource .. py:attribute:: metadata