Skip to content

Conversation

nrjadkry
Copy link
Collaborator

@nrjadkry nrjadkry commented Oct 3, 2025

Related Issue: #2177

Description

This pull request introduces a new feature for managing MapStore extensions directly from the GeoNode Django admin interface. It allows administrators to upload, update, configure, and delete extensions without needing to manually manage static files.

Key Changes

  • Extension Model: A new Django model stores extension metadata, including its name, status, and file path.
  • Django Admin Interface: A user-friendly admin panel is added for full CRUD (Create, Read, Update, Delete) management of the extensions.
  • Automated File Handling: Uses Django signals (post_save, post_delete) to automatically unzip uploaded archives into the static directory and clean them up upon deletion.
  • A custom admin form (ExtensionAdminForm) provides user-friendly validation to prevent uploading extensions with duplicate names.

Screenshots

Django Admin View with the error message showing the duplicate name
image

Copy link

Summary of Changes

Hello @nrjadkry, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust extension management system for MapStore within the application. It provides a new data model to store and track MapStore extensions, implements file upload capabilities with specific validation rules to ensure proper formatting of extension packages, and integrates a comprehensive administration interface for easy management and oversight of these extensions.

Highlights

  • Extension Model Introduction: A new Extension model has been introduced to manage MapStore extensions, allowing for structured storage and management of these components.
  • File Upload and Validation: The system now supports uploading MapStore extensions as zip files, with built-in validation to ensure they are valid zip archives and contain essential files like index.js and index.json at their root.
  • Admin Interface Integration: The new Extension model is fully integrated into the Django admin interface, providing a dedicated ExtensionAdmin with custom form validation to ensure unique extension names derived from uploaded file names.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@nrjadkry nrjadkry marked this pull request as draft October 3, 2025 13:08
@nrjadkry nrjadkry self-assigned this Oct 3, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Extension model for managing MapStore extensions, complete with an admin interface and form validation for uploaded zip files. The changes are generally well-structured, but there is a significant issue where the extension's name is not populated from the uploaded file, which will lead to errors. I have provided a fix for this. Additionally, I've included suggestions to improve code quality and performance.

@nrjadkry nrjadkry marked this pull request as ready for review October 6, 2025 09:51
Copy link

@giohappy giohappy left a comment

Choose a reason for hiding this comment

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

@nrjadkry tests are required.

@nrjadkry nrjadkry requested a review from giohappy October 6, 2025 15:15
@mattiagiupponi mattiagiupponi marked this pull request as draft October 6, 2025 15:45
@nrjadkry nrjadkry marked this pull request as ready for review October 7, 2025 08:54
@mattiagiupponi mattiagiupponi linked an issue Oct 7, 2025 that may be closed by this pull request
Copy link
Collaborator

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

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

@nrjadkry let's wait for confirmation from @mattiagiupponi before applying proposed changes


urlpatterns += [
re_path("/client/extension", views.ExtensionsView.as_view(), name="mapstore-extension"),
re_path("/client/pluginsconfig", views.PluginsConfigView.as_view(), name="mapstore-pluginsconfig"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I tested /client/pluginsconfig locally but I'm seeing only the uploaded extension in the list, all the static plugins are missing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I’m currently using this path for the static plugins. Is this different from what it should be, @allyoucanmap?

        base_config_path = os.path.join(
            settings.PROJECT_ROOT, "static", "mapstore", "configs", "pluginsConfig.json"
        )

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nrjadkry I'm checking again locally, if I access from browser the path /static/mapstore/configs/pluginsConfig.json I have a full list of plugins corresponding to this file:

image

but when I try to access the new endpoint /client/pluginsconfig, I'm seeing only a plugin

image

Comment on lines 113 to 115
"bundle": static(f"extensions/{ext.name}/index.js"),
"translations": static(f"extensions/{ext.name}/translations"),
"assets": static(f"extensions/{ext.name}/assets"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

at the moment we have two variables telling the client the location of extensions, to make this work we should change following variables:

  • MAPSTORE_EXTENSIONS_FOLDER_PATH in geonode settings.py
  • EXTENSIONS_FOLDER_PATH in geonode-mapstore-client context_processor.py

now they are "/static/mapstore/extensions/" but they should be an empty string "" if we want to use absolute paths in this endpoint

Copy link

@giohappy giohappy Oct 10, 2025

Choose a reason for hiding this comment

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

I'm not sure I get your point @allyoucanmap, but I guess:

  • MAPSTORE_EXTENSIONS_FOLDER_PATH (and EXTENSIONS_FOLDER_PATH that gets its value from the same settings) are used by extensions bundled with the project. Right?
  • MAPSTORE_EXTENSIONS_FOLDER_PATH should be defined with STATIC_URL
  • the endpoints should use MAPSTORE_EXTENSIONS_FOLDER_PATH (or EXTENSIONS_FOLDER_PATH) to ensure consistency

Am I wrong?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • MAPSTORE_EXTENSIONS_FOLDER_PATH (and EXTENSIONS_FOLDER_PATH that gets its value from the same settings) are used by extensions bundled with the project. Right?

No, they represent the global location of all the extensions

  • MAPSTORE_EXTENSIONS_FOLDER_PATH should be defined with STATIC_URL
  • the endpoints should use MAPSTORE_EXTENSIONS_FOLDER_PATH (or EXTENSIONS_FOLDER_PATH) to ensure consistency

If we are doing this means MapStore will try to create the request with /static/mapstore/extensions/ (MAPSTORE_EXTENSIONS_FOLDER_PATH) + /static/mapstore/extensions/ExtensionName/index.js (path created in the client/extensions endpoint ).

So if we want always to describe the absolute path inside the extensions configuration MAPSTORE_EXTENSIONS_FOLDER_PATH needs to be an empty string

Choose a reason for hiding this comment

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

I got it now. The client already uses EXTENSIONS_FOLDER_PATH from the geonode config.
As discussed @allyoucanmap we decide to keep the EXTENSIONS_FOLDER_PATH as it is and this PR will be updated to:

  • use the EXTENSIONS_FOLDER_PATH when EXTENSIONS_STATIC_DIR is used
  • the endpoints will use relative paths. i.e.
"bundle": "{ext.name}/index.js"),
"translations": "{ext.name}/translations"),
"assets": "{ext.name}/assets"),
Image

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.

extension model and form validation

3 participants