Skip to content

[Fixes #118] Port rndt to GeoNode 5#121

Merged
etj merged 8 commits intomasterfrom
118_port_to_geonode5
Dec 9, 2025
Merged

[Fixes #118] Port rndt to GeoNode 5#121
etj merged 8 commits intomasterfrom
118_port_to_geonode5

Conversation

@etj
Copy link
Member

@etj etj commented Dec 3, 2025

This PR contains cumulative commits to be squashed for the alignment of this app to GeoNode5 (#118 )

Replaces #119 (was incorrectly targeted at 4.4.x)

First commit features a working metdata editor.
It removes all the pre-5 geonode hooks, templates, etc, and implements:

  • Json schema and handler
  • Labels for metadata fields
  • Thesauri renamed to improve automatic loading
  • Template ISO19115
    • Includes templatetags cleanup
  • database migrations
    • includes model cleanup since LayerRNDT is no longer needed

@etj etj requested a review from Gpetrak December 3, 2025 10:37
@etj etj mentioned this pull request Dec 3, 2025
4 tasks
@etj
Copy link
Member Author

etj commented Dec 3, 2025

Testing required

env preparation

In settings, add the RNDT app and set the metadata template:

INSTALLED_APPS += ("rndt",)
GEONODE_APPS += ("rndt",)

CATALOG_METADATA_TEMPLATE = "xml/template-rndt.xml"

You should also add (manually, at the moment), the thesauri at https://github.com/geosolutions-it/geonode-rndt/tree/118_port_to_geonode5/thesauri

admin

You should create (at least) 3 group profiles.

Then, in the RNDT admin tab, create 2 public administrations, annotating their IPA. The IPA is the code that will be prefixed into the resource's UUID in order to find out to which PA the resource belongs to.

In the RNDT tab you can also associate PA to group profiles using the "Group Profile RNDT" entries. Associate 2 of the group profiles to the 2 created PAs.

test cases

Create a layer, and edit its metadata.

Test: Metadata customization

Metadata should have:

  • a dropdown for access constraints
  • either a dropdown for use constraints, or a freetext; the options should be selectable
  • accuracy field
  • distance field

Test: IPA prefixed UUID

The UUID of a resource should be prefixed with the IPA code of the associated group, in the format "IPA:UUID"

  • Associate a group linked to a PA to the resource --> The related iPA should be present in the fileIdentifier (uuid)
  • Change the associated group, with another associated to a different PA --> the UUID should contain the new IPA
  • Change the associated group, with another NOT associated to a PA --> the UUID should not contain any prefixed IPA

Test: import / export metadata

  • the exported metadata should be in RNDT compliant format
    • the metadata standard name and metadata standard version should report info about the RNDT version
    • there should be present all the aforementioned custom fields (accuracy, resolution), and the LegalConstraint should report INSPIRE related Anchors
  • when importing xml metadata, all the aforementioned custom fields should be parsed and imported

Test: migration

Data from a GeoNode4/RNDT instance should be imported and migrated. This test can be postponed to the first real migration.

Copy link
Member

@Gpetrak Gpetrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giohappy @etj

Tests

Test: Metadata customization: Passed (no comments)
Test: IPA prefixed UUID : Passed (no comments)
Test: import / export metadata
In the exported metadata the RNDT is included in the metadataStandardName

<gmd:metadataStandardName>
    <gco:CharacterString>Linee Guida RNDT</gco:CharacterString>
  </gmd:metadataStandardName>

but not in metadataStandardVersion

<gmd:metadataStandardVersion>
    <gco:CharacterString>2.0</gco:CharacterString>
  </gmd:metadataStandardVersion>

Also, all the custom fields of the libraries are existed in the exported metadata except from this field: ConditionsApplyingToAccessAndUse
I noticed the same with the above, when I imported a metadata xml.

Setup

Regarding the setup of the library in a new GeoNode database:
If I include the library in the settings and then run the manage.py migrate in a fresh database I got the following error:

Traceback (most recent call last):
  File "/home/gpetr/.virtualenvs/geonode_env/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "base_restrictioncodetype" does not exist
LINE 1: ...ion", "base_restrictioncodetype"."is_choice" FROM "base_rest... 

Instead, if I run the manage.py migrate in two steps (1) in the main GeoNode (without the library) and (2) after including the library, the migrations are registered correctly.

@etj
Copy link
Member Author

etj commented Dec 3, 2025

The required format for metadataStandardName and metadataStandardVersion is

  <gmd:metadataStandardName>
      <gco:CharacterString>Linee Guida RNDT</gco:CharacterString>
   </gmd:metadataStandardName>
   <gmd:metadataStandardVersion>
      <gco:CharacterString>2.0</gco:CharacterString>
   </gmd:metadataStandardVersion>

ConditionsApplyingToAccessAndUse is encoded in this template block:

         <gmd:resourceConstraints>
            <gmd:MD_LegalConstraints>
               <gmd:useConstraints>
                  <gmd:MD_RestrictionCode 
                      codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_RestrictionCode"
                      codeListValue="otherRestrictions">otherRestrictions</gmd:MD_RestrictionCode>
               </gmd:useConstraints>
               <gmd:otherConstraints>
               {% if metadata.rndt_ConditionsApplyingToAccessAndUse.inspire_url %}
                  <gmx:Anchor xlink:href="{{metadata.rndt_ConditionsApplyingToAccessAndUse.url}}">{{metadata.rndt_ConditionsApplyingToAccessAndUse.url|rndt_get_keyword_label_by_about}}</gmx:Anchor>
               {% else %}
                  <gco:CharacterString>{{metadata.rndt_ConditionsApplyingToAccessAndUse.freetext}}</gco:CharacterString>
               {% endif %}
               </gmd:otherConstraints>
            </gmd:MD_LegalConstraints>
         </gmd:resourceConstraints>

@Gpetrak
Copy link
Member

Gpetrak commented Dec 3, 2025

@etj thank you for providing more information.
Based on your comment I'm updating here my review:

Tests

Test: Metadata customization: Passed (no comments)
Test: IPA prefixed UUID : Passed (no comments)
Test: import / export metadata: Passed (no comments)

Setup

Regarding the setup of the library in a new GeoNode database:
If I include the library in the settings and then run the manage.py migrate in a fresh database I got the following error:

Traceback (most recent call last):
  File "/home/gpetr/.virtualenvs/geonode_env/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "base_restrictioncodetype" does not exist
LINE 1: ...ion", "base_restrictioncodetype"."is_choice" FROM "base_rest... 

Instead, if I run the manage.py migrate in two steps (1) in the main GeoNode (without the library) and (2) after including the library, the migrations are registered correctly.


def __init__(self) -> None:
super().__init__()
self.otherRestrictions = RestrictionCodeType.objects.filter(identifier="otherRestrictions").first() or \
Copy link
Member

@Gpetrak Gpetrak Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etj this line: self.otherRestrictions = RestrictionCodeType.objects.filter(identifier="otherRestrictions").first() or \ produces a migration error:

Traceback (most recent call last):
  File "/home/gpetr/.virtualenvs/geonode_env/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "base_restrictioncodetype" does not exist
LINE 1: ...ion", "base_restrictioncodetype"."is_choice" FROM "base_rest...

I propose to replace that line with something like:

@property
def otherRestrictions(self):
    from geonode.base.models import RestrictionCodeType
    return (
        RestrictionCodeType.objects.filter(identifier="otherRestrictions").first()
         r RestrictionCodeType.objects.filter(description="otherRestrictions").first()
    )
``

@etj etj self-assigned this Dec 9, 2025
@etj etj merged commit 83f7667 into master Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants