Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(apcd-cms): fp-1837 limit menu visibility by group #45

Merged
merged 7 commits into from
Nov 10, 2022

Conversation

wesleyboar
Copy link
Member

@wesleyboar wesleyboar commented Nov 10, 2022

Overview

Implement custom logic in CMS nav template.

Related

Changes

  • clone cms nav template, but use template tag
  • add template tag with menu view permission logic

Testing

Important

You must re-build and re-up containers after checking out this branch.

docker-compose -f docker-compose.dev.yml down && docker-compose -f docker-compose.dev.yml build --no-cache && docker-compose -f docker-compose.dev.yml up --force-recreate --detach

Setup

As admin,

  1. Create user groups:
    • SUBMITTER_USER
    • SUBMITTER_ADMIN
    • APCD_ADMIN
  2. Create a test user that:
    • is "Active"
    • has "Staff status"
    • not "Superuser"
  3. Create three pages that are visible in menu:
    • Home
    • Submissions (Advanced Settings: ID: submissions)
    • Administration (Advanced Settings: ID: administration)

Steps

  1. While not logged in, login as test user.
    In a private window, so you can check admin steps in your main window.
  2. As admin, for test user, choose group SUBMITTER_USER.
  3. As test user, load any CMS page.
  4. Verify user sees this navigation:
    • Home
    • Submissions
  5. For test user, choose group SUBMITTER_ADMIN.
  6. Verify user sees this navigation:
    • Home
    • Submissions
  7. For test user, choose group APCD_ADMIN.
  8. Verify user sees this navigation:
    • Home
    • Submissions
    • Administration
  9. For test user, choose no groups (i.e. un-assign APCD_ADMIN group).
  10. Verify user sees this navigation:
    • Home

UI

Step 4 Step 6 Step 8 Step 10
Step 3 Step 6 Step 9 Step 12

Notes

Next: Add the same template logic in CMS, and add a template tag of the same name, but whose simple_tag always returns True, and that has documentation that the template tag may be overwritten (like in APCD). Then confirm that APCD is unaffected when using the new Core CMS image that has that.

Limit what nav items are shown to user based on their group.

There should be a more parametric way to do this, so we can:
- integrate this into core
- rely on CMS page group perms, not code
TO DO:
1. Clone Core CMS nav menu markup.
2. Use new logic within that cloned markup.
3. Migrate to Core CMS:
    - nav can come as is
    - template tag need always return true
TO DO:
1. Clone Core CMS nav menu markup.
2. Use new logic within that cloned markup.
3. Migrate to Core CMS:
    - nav can come as is
    - template tag need always return true
TO DO:
1. [x] Clone Core CMS nav menu markup.
2. [x] Use new logic within that cloned markup.
3. Migrate to Core CMS:
    - nav can come as is
    - template tag need always return true
@wesleyboar wesleyboar changed the title test(apcd-cms): fp-1837 overwrite cms nav poc test(apcd-cms): fp-1837 limit menu visibility by group Nov 10, 2022
wesleyboar added a commit to TACC/Core-CMS that referenced this pull request Nov 10, 2022
Manage menu item visibility by group.

A minimal noop that serves as an example for Core-CMS-Custom apps.

Example Usage: TACC/Core-CMS-Custom#45
wesleyboar added a commit to TACC/Core-CMS that referenced this pull request Nov 10, 2022
Manage menu item visibility by group.

A minimal noop that serves as an example for Core-CMS-Custom apps.

Example Usage: TACC/Core-CMS-Custom#45
Copy link
Contributor

@Strmiska Strmiska left a comment

Choose a reason for hiding this comment

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

Pulled and tested locally. LGTM!

@Strmiska Strmiska merged commit 375d1b8 into main Nov 10, 2022
@Strmiska Strmiska deleted the task/fp-1837-nav-perms-logic branch November 10, 2022 23:34
Copy link
Contributor

@fnets fnets left a comment

Choose a reason for hiding this comment

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

LGTM! Great turnaround

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.

3 participants