Remove staff member required decorator - #18
Merged
matteius merged 4 commits intoAug 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Removes @staff_member_required from form builder view functions to make them reusable outside the admin registration, and adds regression tests to ensure the admin-mounted endpoints remain staff-gated via admin_site.admin_view.
Changes:
- Dropped
@staff_member_requiredfrom all form builder views inform_builder_views.py. - Added “requires staff” regression tests for multiple form builder/admin endpoints.
- Documented the change in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_builders.py | Adds regression tests asserting non-staff users are blocked from admin-mounted form builder endpoints. |
| django_forms_workflows/form_builder_views.py | Removes @staff_member_required decorators from form builder endpoints, relying on URL-layer gating. |
| CHANGELOG.md | Notes removal of @staff_member_required and the rationale (admin routes already wrapped in admin_view). |
Suppressed comments (1)
django_forms_workflows/form_builder_views.py:36
- Removing
@staff_member_requiredfrom these views makes them rely entirely on the URL registration for access control. That’s true for the admin URLs (they’re wrapped viaself.admin_site.admin_view(...)indjango_forms_workflows/admin.py:get_urls()), butdjango_forms_workflows/form_builder_urls.pycurrently maps these views directly (e.g.path("new/", form_builder_views.form_builder_view, ...)) withoutadmin_view/staff gating. Including that URLConf as documented would expose builder and write endpoints to non-staff/anonymous users.
@require_GET
def form_builder_templates(request):
"""
API endpoint to list available form templates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1408
to
+1412
| def test_builder_new_view_requires_staff(self, client, user): | ||
| client.force_login(user) | ||
| url = _fb_url("builder/new/") | ||
| resp = client.get(url) | ||
| assert resp.status_code in (302, 403) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes staff member required decorator to allow view reuse while adding regression tests to make sure future changes don't result in accidental access to gated views