Skip to content

[Fixes #14801] Metadata: improve SpatialRepresentationType handling - #14802

Merged
etj merged 1 commit into
masterfrom
14801_spatial_representation_type_label
Dec 1, 2026
Merged

etj merged 1 commit into
masterfrom
14801_spatial_representation_type_label

Conversation

@etj

@etj etj commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Show a human-readable label for spatial representation type

The spatial representation type field showed the raw ISO identifier (vector, grid, textTable, ...) instead of a human-readable label, in two places:

The editor case (#14801) was a simple title lookup: SpatialRepresentationTypeSubHandler was using the identifier as the oneOf title instead of gn_description.

The view-metadata case (#14810) couldn't be fixed the same way: that template has no schema access, so it has no way to resolve a label from a plain oneOf-enumerated string value — the value stored in the resource's metadata was just the bare identifier (e.g. "vector"), with no label alongside it. Fixing this required changing what the field's value actually carries, not just how the editor displays it.

Fix

  • SpatialRepresentationTypeSubHandler: title now uses gn_description instead of identifier for the (now superseded) oneOf entries.
  • Data migration: short English labels (Vector, Grid, Text table, TIN / Triangulated irregular network, Stereo model, Video) set on existing SpatialRepresentationType rows, guarded to only touch rows still holding the original fixture description. initial_data.json updated for fresh installs.
  • Schema redesign (Metadata: SpatialRepresentationType rendering #14810): spatial_representation_type changed from a plain string with a oneOf enum to an {id, label} object, the same convention already used for category and license. The value serialized onto a resource now carries its own label (e.g. {"id": "vector", "label": "Vector"}), so any consumer — including the view-metadata template — can render it without a schema-side lookup.
  • Replaced the oneOf enum with an autocomplete endpoint (GET /api/v2/metadata/autocomplete/spatial_representation_types, optional ?q= filter), matching the categories/licenses autocomplete pattern, instead of hardcoding the options in the schema.
  • full_metadata.xml output is unchanged — it intentionally keeps using the bare ISO identifier.

Files

  • geonode/metadata/handlers/base.py — SpatialRepresentationTypeSubHandler rewritten to the autocomplete/object pattern.
  • geonode/metadata/schemas/base.json — spatial_representation_type schema changed to {id, label} object.
  • geonode/metadata/api/views.py / geonode/metadata/api/urls.py — new spatial_representation_types_autocomplete endpoint.
  • geonode/metadata/tests/test_handlers.py / geonode/metadata/tests/tests.py — updated/added tests for the new handler behavior and the autocomplete endpoint.
  • (from the earlier Metadata: improve SpatialRepresentationType handling #14801 fix, already merged into this branch) data migration + initial_data.json + earlier test_handlers.py label assertions.

Checklist

Reviewing is a process done by project maintainers, mostly on a volunteer basis. We try to keep the overhead as small as possible and appreciate if you help us to do so by completing the following items. Feel free to ask in a comment if you have troubles with any of them.

For all pull requests:

  • Confirm you have read the contribution guidelines
  • You have sent a Contribution Licence Agreement (CLA) as necessary (not required for small changes, e.g., fixing typos in the documentation)
  • Make sure the first PR targets the master branch, eventual backports will be managed later. This can be ignored if the PR is fixing an issue that only happens in a specific branch, but not in newer ones.

The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):

  • There is a ticket in https://github.com/GeoNode/geonode/issues describing the issue/improvement/feature (a notable exemption is, changes not visible to end-users)
  • The issue connected to the PR must have Labels and Milestone assigned
  • PR for bug fixes and small new features are presented as a single commit
  • PR title must be in the form "[Fixes #<issue_number>] Title of the PR"
  • New unit tests have been added covering the changes, unless there is an explanation on why the tests are not necessary/implemented

Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.

@etj etj added this to the 5.1.2 milestone Nov 30, 2026
@etj
etj requested review from Gpetrak and a balanced review from Copilot November 30, 2026 14:59
@etj etj self-assigned this Nov 30, 2026
@cla-bot cla-bot Bot added the cla-signed CLA Bot: community license agreement signed label Nov 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the update to human-readable spatial representation labels.

No open issues 🎉

What changed in this PR

Updates spatial representation type labels in the metadata editor to human-readable names, addressing #14801 while leaving ISO identifiers in XML output unchanged.

Changes:

  • Uses translated gn_description values for dropdown labels.
  • Adds short labels to fixtures and a guarded data migration that preserves customized descriptions.
  • Updates the handler test to expect the display label rather than the identifier.
File Description
geonode/​metadata/​tests/​test_handlers.py Updates test data and assertions for human-readable labels.
geonode/​metadata/​handlers/​base.py Uses translated gn_description values as option titles.
geonode/​base/​migrations/​0103_spatialrepresentationtype_gn_description_labels.py Adds a reversible migration guarded by original fixture descriptions.
geonode/​base/​fixtures/​initial_data.json Supplies six short labels for fresh installations.

Review effort: Balanced

@etj
etj requested review from sijandh35 and removed request for Gpetrak November 30, 2026 15:08
@etj etj modified the milestones: 5.1.2, 5.2.0 Nov 30, 2026
@etj
etj force-pushed the 14801_spatial_representation_type_label branch from 62a6fe0 to c68a849 Compare December 1, 2026 14:19
@etj
etj requested a review from sijandh35 December 1, 2026 14:23
@etj
etj merged commit 644c712 into master Dec 1, 2026
15 checks passed
@etj
etj deleted the 14801_spatial_representation_type_label branch December 1, 2026 15:23
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

The backport to 5.1.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.1.x 5.1.x
# Navigate to the new working tree
cd .worktrees/backport-5.1.x
# Create a new branch
git switch --create backport-14802-to-5.1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 644c7127e69f9394ce9ec1076ade0efac62cb908
# Push it to GitHub
git push --set-upstream origin backport-14802-to-5.1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.1.x

Then, create a pull request where the base branch is 5.1.x and the compare/head branch is backport-14802-to-5.1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 5.1.x cla-signed CLA Bot: community license agreement signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants