Skip to content

feat: DSAPP-106 CMS Plugin for User Guide Link#1653

Open
wesleyboar wants to merge 18 commits intomainfrom
feat/DSAPP-106-cms-page-user_guide_link-from-model
Open

feat: DSAPP-106 CMS Plugin for User Guide Link#1653
wesleyboar wants to merge 18 commits intomainfrom
feat/DSAPP-106-cms-page-user_guide_link-from-model

Conversation

@wesleyboar
Copy link
Copy Markdown
Collaborator

@wesleyboar wesleyboar commented Sep 22, 2025

Overview

Add plugin to render User Guide link on CMS app overview page.

Status

Related

Changes

  • added CMS plugin and its model and admin form
  • added function to derive app from URL path
  • added function to know whether context is editing Text

Testing & UI

  1. Create/Find an App Listing Entry with an href value.
    E.g. Ground-Motion Portal app. Scroll to "CMS Display Options:".

    1
  2. Create/Open page at a path that matches one of an App Listing Entry.
    E.g. /use-designsafe/tools-applications/hazard-apps/ground-motion-portal/.

    2
  3. On page, add "User Guide Link" plugin; do not choose app.

  4. Verify link is rendered that opens page at correct path for User Guide.
    E.g. /user-guide/tools/hazard/#scec.

    3-4.mov

    ✅ Link opens correct page. Video did not capture it.

  5. Change page path to one that does not match an app.

  6. Verify:

    • link is not rendered
    • text "User guide not found." is rendered
    • server does not crash
    5-6.mov

    ✅ App can not be guessed at wrong path, so no button.

  7. Change "User Guide Link" plugin; choose app.

  8. Verify button URL is for the app chosen.

    7-8.mov

    ✅ Link opens correct page. Video did not capture it.

Notes

The new function get_instance_from_url could be used by existing plugins, RelatedApps and AppVariants, so that their models, AppVariantsPlugin and RelatedAppsPlugin, need not be used.

@wesleyboar wesleyboar marked this pull request as draft September 22, 2025 18:15
@wesleyboar wesleyboar marked this pull request as ready for review September 23, 2025 16:47
@wesleyboar wesleyboar changed the title feat: DSAPP-106 CMS user guide link from app model feat: DSAPP-106 CMS Plugin for User Guide Link Sep 23, 2025
…github.com:DesignSafe-CI/portal into feat/DSAPP-106-cms-page-user_guide_link-from-model
def get_entry_instance(url):
"""Helper function to get an AppListingEntry instance based on URL."""

app_listing_entries = AppListingEntry.objects.filter(enabled=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you able to find by the href here, i.e. AppListingEntry.objects.get(href=url)?

Copy link
Copy Markdown
Collaborator Author

@wesleyboar wesleyboar Feb 4, 2026

Choose a reason for hiding this comment

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

I think not reliably.

Using exact match would require:

  • data entry be exact (include trailing slash)
  • user be on page with URL that does not have hash nor query params
Details

The url passed is context.get("request").path, which can include:

  • trailing slashes (e.g. /use-designsafe/…/adcirc/)
  • query parameters (e.g. ?tab=overview, ?edit, ?toolbar_off)
  • hash (e.g. #specific-element)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you parse the url to conform to just the path?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, like this?

    from urllib.parse import __
    path = ... # logic via `urllib` taht gets path from url
    app_listing_entries = AppListingEntry.objects.get(href=path)

And

        help_texts = {
            "href": (
                "Use absolute path. Include trailing slash."
            ),
        }

— yeah?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah exactly 👍

Copy link
Copy Markdown
Collaborator Author

@wesleyboar wesleyboar Feb 5, 2026

Choose a reason for hiding this comment

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

Okay.

@wesleyboar, prevent false positives e.g. what/ considered a match of whatever/, i/am/good/ considered a match of i/am/good--test/solution.

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