Skip to content

Migrate Geoportal<->mp-data_manager integration into mp-layers#25

Open
rhodges wants to merge 11 commits intomainfrom
develop
Open

Migrate Geoportal<->mp-data_manager integration into mp-layers#25
rhodges wants to merge 11 commits intomainfrom
develop

Conversation

@rhodges
Copy link
Copy Markdown
Member

@rhodges rhodges commented May 6, 2026

This pull request introduces new functionality for mapping catalog records to visualizable layers, along with improvements to the Theme model, integrating Layer admin forms with a paired GeoPortal catalog instance, and test coverage. It adds two new properties to the Theme model for retrieving direct and all descendant layers, implements a new view and endpoint for catalog-to-layer mapping, and provides comprehensive tests for these features. Additionally, it includes minor JavaScript and CSS tweaks and some cleanup in template scripts.

New functionality for catalog mapping and Theme model:

  • Corrects broken code copied from mp-data_manager to dynamically alter Layer form options when tied to a catalog record in GeoPortal
  • Added layers and all_layers properties to the Theme model to retrieve direct and all descendant visible layers, respectively. These are used to identify "visualizable" layers for the catalog.
  • Introduced the get_portal_catalog_map view and corresponding endpoint /get_portal_catalog_map, which returns a mapping from catalog record names to layer primary keys for visible layers under top-level themes. [1] [2]

Testing improvements:

  • Added thorough tests for the new Theme.layers, Theme.all_layers properties, and the get_portal_catalog_map view, covering edge cases and visibility rules.

JavaScript and CSS adjustments:

  • Improved error handling and utility functions in catalog JavaScript, including a new union function and error logging for AJAX failures. [1] [2]
  • Minor CSS tweaks to improve form field appearance in the admin interface.
  • Fixed the order of JavaScript initialization in the admin layer form. [1] [2]

Template cleanup:

  • Removed unused Knockout.js script imports from admin change form templates. [1] [2]

rhodges and others added 11 commits April 30, 2026 14:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
support and replace data_manager's get_portal_catalog_map view
Supporting GeoPortal catalog assists in Layer admin form
Comment thread layers/models.py

# This property gets an array of all of the Layer records that are direct children of this Theme
# This is particularly used by the 'get_portal_catalog_map' view to identify 'visualizable' layers
# in the catalog.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Love the comments. Would it be helpful to have these as doc strings for the properties so that they are visible in vscode?

Comment thread layers/views.py

return JsonResponse(data)

# This allows the catalog page to link to 'visualize' layers, which requires knowing the layerID that corresponds to a
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this could also be a docstring

Comment thread layers/views.py
# given catalog record. Only layers with a catalog_name field will be included in this mapping.
def get_portal_catalog_map(request):
data = {}
if settings.CATALOG_TECHNOLOGY == "GeoPortal2":
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure how we feel about constants in this codebase, but if GeoPortal2 is used elsewhere it might be nice to make that a constant.

Comment thread layers/models.py
layers = self.layers
for child_order in child_theme_orders:
if child_order.content_object.is_visible:
layers = layers + child_order.content_object.all_layers
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

likely a python noob question: Why did you use + here and not append?

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