Skip to content

Add a relation type to LinkedResource #14780

Open

Description

@giohappy

Currently LinkedResource only stores a generic relationship between a source and a target resource. The only distinction is the internal flag, which the client uses to show "Uses / Used by" for maps and their datasets, and "Linked to / Linked by" for everything else. The meaning of the relationship is implicit in the code, both in the backend and in the client.

We want to add a relation_type field to make it explicit. It reads as <source> <relation_type> <target>:

  • related: the generic link set by users from the metadata editor or the API (default)
  • uses: a map and its datasets, calculated from the map layers as it is now
  • clone_of: set when a resource is cloned (Save as)

clone_of is the first new use. At the moment a cloned resource keeps no trace of the resource it was cloned from.

The linked_resources API will return the relation_type of each item and accept it as a filter. internal will still be returned for backward compatibility, but it's deprecated.

The link between a map and its map viewer is also a generic link, and the client finds the viewer by looking for a linked resource of type mapviewer. It should get its own type, but this requires changes in the client too, so it will be done later. In the meantime the map viewer will be excluded from the "Related resources" field of the metadata editor for maps, where it can be removed or replaced by mistake.

Activity

  1. self-assigned this
    on Nov 20, 2026
  2. added this to the 5.2.0 milestone on Nov 20, 2026
  3. mattiagiupponi commented on Nov 23, 2026

    @mattiagiupponi
    Contributor

    Few notes:

    1. Cloning a map still copies the related link to its map viewer, so the clone shares the original's viewer. The copy should skip it.
    2. The migration turns internal=True rows into uses, but the description says all existing links become related
    3. The migration rollback sets every row back to internal=False. Add a reverse function that restores internal=True for uses.
    4. Minor: in linked_resources, use a fixed error message instead of echoing the user's relation_type, and filter relation_type in the DB. In the tests
  4. added 2 commits that reference this issue on Nov 24, 2026
    ac30928
    53265ff
  5. giohappy commented on Nov 26, 2026

    @giohappy
    ContributorAuthor
    1. Cloning a map still copies the related link to its map viewer, so the clone shares the original's viewer. The copy should skip it.

    Do we really want to exclude the viewer from the cloned map? I'm not so sure...

    1. The migration turns internal=True rows into uses, but the description says all existing links become related

    The idea is that in case someone (third party code, whatevere) stored that value, the equivalent with the new types would be "uses".
    This is only a theoritcal edge case, because GeoNode's current code never stored internal=True , and it will not store "use". They're computed at runtime.
    So the migration covers edge cases, not the current usage from GeoNode itself.

    1. The migration rollback sets every row back to internal=False. Add a reverse function that restores internal=True for uses.

    Again, this would cover an edge case. In reality, nothing will save "uses" now, and nothing would use internal=True after a revert. This is just in case some custom code would have.

    I would probably remove both the forward and backwards migration steps.

    1. Minor: in linked_resources, use a fixed error message instead of echoing the user's relation_type

    Why?

  6. giohappy commented on Nov 26, 2026

    @giohappy
    ContributorAuthor

    @mattiagiupponi I've removed the forward migration that converts internal=True to uses. It was... useless :)

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions