Skip to content

Dev perms - #196

Merged
mihalikv merged 10 commits into
mainfrom
dev_perms
Jul 3, 2026
Merged

Dev perms#196
mihalikv merged 10 commits into
mainfrom
dev_perms

Conversation

@mihalikv

@mihalikv mihalikv commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@mihalikv
mihalikv marked this pull request as ready for review July 3, 2026 13:07
@mihalikv

mihalikv commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@MartinCervenkaSB MartinCervenkaSB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of SBAdminPermissionWidget (permission tree widget, groups mode, JS search, tests).

Concerns

  • Unbound/add forms preselect every permission in the queryset — a fail-open default that is also undocumented in the new AGENTS.md section.
  • Re-rendering a bound form after a tampered POST (non-numeric IDs) raises an uncaught ValueError → 500.
  • _standard_action splits the codename from the right, so standard permissions of models with underscores in their name are silently dropped from rendering.
  • Checkbox DOM ids are not prefixed with the widget id — two permission widgets on one page collide.
  • Global .tooltip, .popover { z-index: 1020 } puts overlays below Bootstrap modals (1055), which can hide this widget's own body-container tooltips inside modals.
  • {{ form.media }} is now rendered for all modal forms — widget scripts re-execute on every modal open; other widgets' media may not be idempotent.

Nits

  • group_by_model parameter of _build_auto_context is never used with True (dead branch).
  • Duplicated empty <label> for the section select-all toggle.
  • Section count is server-rendered as 0/N even when selections exist (JS corrects it after init).
  • Duplicated view_dashboard get_or_create block in test setUpTestData.
  • Two consecutive identical CSS selectors .permission-tree__custom-row > input[type="checkbox"].toggle + label could be merged into one rule.
  • sb_admin_widget = True is already inherited from SBAdminBaseWidget.

Questions for the author

  1. Is select-all-by-default on add forms deliberate (e.g. for the Neoship account use case)? If so, please document it in AGENTS.md; if not, consider an opt-in flag.
  2. The section "select all" toggle also flips permissions currently hidden by an active search filter — intended?
  3. What motivated the global tooltip/popover z-index change to 1020 (below Bootstrap's modal at 1055)?

What looks good

  • Single-query context building, locked in with an assertNumQueries(1) test.
  • JS search highlighting escapes HTML before innerHTML — no XSS through permission names.
  • Strict app_label.model:codename refs with clear ImproperlyConfigured errors, and group-referenced permissions are deduplicated from the automatic leftover sections.
  • Diacritics-insensitive, astral-safe search index with correct offset mapping.
  • PEP 562 lazy export in widgets.py avoids the import cycle cleanly.
  • Comprehensive test suite covering both modes, indeterminate state, and misconfiguration errors.

Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/templates/sb_admin/widgets/permission_tree.html Outdated
Comment thread src/django_smartbase_admin/static/sb_admin/src/css/_components.css
Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/templates/sb_admin/widgets/permission_tree.html Outdated
Comment thread src/django_smartbase_admin/templates/sb_admin/widgets/permission_tree.html Outdated
Comment thread src/django_smartbase_admin/tests/test_permission_widget.py Outdated
Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4809f636ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/admin/permission_widget.py Outdated
Comment thread src/django_smartbase_admin/templates/sb_admin/widgets/permission_tree.html Outdated
mihalikv added 4 commits July 3, 2026 15:49
Simplify permission tree handling by removing indeterminate states, improving search functionality, and refactoring selection logic. Update related tests and documentation.
…rmission tree component

This new CSS file consolidates and organizes styles for the permission tree, enhancing the UI structure and ensuring consistent styling across various elements within the component.
@mihalikv

mihalikv commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review again

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 46515b99ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/django_smartbase_admin/admin/permission_widget.py
mihalikv added 2 commits July 3, 2026 16:26
… handling

Added a detailed explanation regarding the all-or-nothing behavior of group options in the permission system, including guidance on managing existing groups and users during updates to permission sets.
@mihalikv
mihalikv merged commit 87f6bb4 into main Jul 3, 2026
2 checks passed
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