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

feat: better group perms mgmt #895

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

wesleyboar
Copy link
Member

@wesleyboar wesleyboar commented Nov 12, 2024

Overview

Allow developers to offer Groups with overlapping permissions but less redundant code.

Related

Changes

  • added a util.py
  • added a function add_perm
  • changed group permissions to use new utility function
  • added "Grid Editor (Basic)" and "Grid Editor (Advanced)"
  • added permission Can change static placeholder1

Testing

via Custom Migration

  1. Create/Open a Core-CMS instance.
  2. In the CMS container2, add groups implicitly via migration:
    python manage.py migrate taccsite_cms
  3. Verify Groups in admin UI, and their permissions, are present.
  4. Reverse that migration:
    python manage.py migrate taccsite_cms zero
  5. Verify Groups in admin, and their permissions, are absent.
  6. Add groups explicitely via migration:
    python manage.py migrate taccsite_cms 0001_add_groups
  7. Verify Groups in admin, and their permissions, are present.
  8. Reverse that migration:
    python manage.py migrate taccsite_cms zero
  9. Verify Groups in admin, and their permissions, are absent.

via Mgmt. Command

  1. Create/Open a Core-CMS instance.
  2. In the CMS container2, run:
    • python manage.py set_group_perms grid_editor_basic grid_editor_advanced text_editor_basic text_editor_advanced media_editor_basic media_editor_advanced news_writer_basic news_writer_advanced
  3. In CMS admin UI, verify those 8 groups are created.
  4. Verify the groups each have relevant permissions.
    I merely skimmed the results.

UI

via Custom Migration

implicit.migrate.then.revert.mov
explicit.migrate.then.revert.mov

Note

The SearchAppHook error is unrelated. I have a local page expecting code from another branch.

via Mgmt. Command

before after
before after
grid media news text
grid basic media basic news basic text basic
grid adv media adv news adv text adv

Footnotes

  1. Let's editor see "Edit" and "View published" button. WTCS users could not. One avid TACC editor sometimes can not.

  2. Run docker exec -it core_cms /bin/bash to enter CMS container. 2

* chore: remove unused imports

* refactor: add & use add_perm utility function

* docs: add & use add_perm utility function

* docs: missing spaces

* docs: missing spaces
* feat: grid editor (⚠️ untested)

* fix: grid editor "row" not "rw"

* fix: grid editor permission name typos
@wesleyboar wesleyboar force-pushed the epic/cmd-189-simple-group-mgmt branch from e3762f6 to 42190a7 Compare November 15, 2024 23:46
* refactor: consolidate add_perm calls (⚠️ untested)

* refactor: news_writer (⚠️ untested) & renames

* fix: user lacks [Edit] / [View published] buttons

* fix: errors adding permissions
@wesleyboar wesleyboar marked this pull request as ready for review November 18, 2024 22:26
@wesleyboar wesleyboar changed the title feat: simplify group mgmt for admins feat: simplify group perms mgmt Nov 18, 2024
@wesleyboar wesleyboar changed the title feat: simplify group perms mgmt feat:"better" group perms mgmt Nov 18, 2024
@wesleyboar wesleyboar changed the title feat:"better" group perms mgmt feat: better group perms mgmt Nov 18, 2024
Copy link
Member Author

@wesleyboar wesleyboar left a comment

Choose a reason for hiding this comment

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

Tasks
From joint peer code review on Zoom:

  • Document what each of these groups provide for the user (one sentence) i.e. why you would give someone this group.
  • Add a custom migration for these. (New migration might remove/change permissions.)
    • The migration could empty the existing permission form existing groups, then run the scripts.
    • A good primer on migration.

@wesleyboar wesleyboar marked this pull request as draft November 19, 2024 20:12
@wesleyboar
Copy link
Member Author

@taoteg, please review updated documentation.

Instruct developer how to update all instances of CMS via migrations.
Testing:
0. Have a running CMS.
1. Enter CMS Docker container.
    <sup>e.g. docker exec -it core_cms /bin/bash</sup>
2. Add groups implicitely via migration:
   `python manage.py migrate taccsite_cms`
3. Verify [groups], and their permissions, are **present**.
4. Reverse that migration:
    `python manage.py migrate taccsite_cms zero`
5. Verify [groups], and their permissions, are **absent**.
6. Add groups explicitely via migration:
    `python manage.py migrate taccsite_cms 0001_add_groups`
7. Verify [groups], and their permissions, are **present**.
8. Reverse that migration:
    `python manage.py migrate taccsite_cms zero`
9. Verify [groups], and their permissions, are **absent**.

[groups]: https://localhost:8000/admin/auth/group
@wesleyboar
Copy link
Member Author

@jarosenb & @rstijerina, please review new taccsite_cms/migrations/ and (optionally) example migrations for future devs.

@wesleyboar wesleyboar marked this pull request as ready for review December 10, 2024 23:45
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.

1 participant