-
-
Notifications
You must be signed in to change notification settings - Fork 313
Add organization switching for administrators managing multiple organizations #5257
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
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Note Free review on us!CodeRabbit is offering free reviews until Wed Dec 17 2025 to showcase some of the refinements we've made. Comment |
Co-authored-by: DonnieBLT <[email protected]>
Co-authored-by: DonnieBLT <[email protected]>
❌ Pre-commit checks failedThe pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them: # Install pre-commit if you haven't already
pip install pre-commit
# Run pre-commit on all files
pre-commit run --all-files
# Or run pre-commit on staged files only
pre-commit runAfter running these commands, the pre-commit hooks will automatically fix most issues. 💡 Tip: You can set up pre-commit to run automatically on every commit by running: pre-commit installPre-commit outputFor more information, see the pre-commit documentation. |
Co-authored-by: DonnieBLT <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds organization switching functionality to the administrator dashboard, allowing users who manage multiple organizations to switch between them and persist their selection across sessions. The changes enable non-superuser administrators and managers to access the organization dashboard with proper permission controls.
Key Changes:
- Modified
admin_organization_dashboardview to support organization switching with session-based persistence - Updated
admin_organization_dashboard_detailview to allow access for organization admins and managers, not just superusers - Redesigned the admin dashboard template with a modern UI using Tailwind CSS, including a dropdown switcher for multiple organizations
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| website/views/organization.py | Added organization filtering based on user role (admin/manager), implemented session-based organization switching with query parameter handling, and updated permission checks for detail view |
| website/tests/test_organization.py | Added comprehensive test suite (OrganizationSwitchingTests) covering access permissions, switching functionality, session persistence, and edge cases |
| website/templates/admin_dashboard_organization.html | Complete UI redesign with Tailwind CSS, added organization switcher dropdown, visual indicators for selected organization, and improved organization listing with logos and status badges |
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: DonnieBLT <[email protected]>
❌ Pre-commit checks failedThe pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them: # Install pre-commit if you haven't already
pip install pre-commit
# Run pre-commit on all files
pre-commit run --all-files
# Or run pre-commit on staged files only
pre-commit runAfter running these commands, the pre-commit hooks will automatically fix most issues. 💡 Tip: You can set up pre-commit to run automatically on every commit by running: pre-commit installPre-commit outputFor more information, see the pre-commit documentation. |
|
👋 Hi @Copilot! This pull request needs a peer review before it can be merged. Please request a review from a team member who is not:
Once a valid peer review is submitted, this check will pass automatically. Thank you! |
❌ Tests failedThe Django tests found issues that need to be fixed. Please review the test output below and fix the failing tests. How to run tests locally# Install dependencies
poetry install --with dev
# Run all tests
poetry run python manage.py test
# Run tests with verbose output
poetry run python manage.py test -v 3
# Run a specific test
poetry run python manage.py test app.tests.TestClass.test_methodTest output (last 100 lines)For more information, see the Django testing documentation. |
|
@copilot fix Review the code at the location below. A potential bug has been identified by an AI Location: website/templates/admin_dashboard_organization.html#L220-L236 Potential issue: The |
Co-authored-by: DonnieBLT <[email protected]>
Fixed in commit de86518. The JavaScript has been moved from the non-existent |
❌ Pre-commit checks failedThe pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them: # Install pre-commit if you haven't already
pip install pre-commit
# Run pre-commit on all files
pre-commit run --all-files
# Or run pre-commit on staged files only
pre-commit runAfter running these commands, the pre-commit hooks will automatically fix most issues. 💡 Tip: You can set up pre-commit to run automatically on every commit by running: pre-commit installPre-commit outputFor more information, see the pre-commit documentation. |
❌ Tests failedThe Django tests found issues that need to be fixed. Please review the test output below and fix the failing tests. How to run tests locally# Install dependencies
poetry install --with dev
# Run all tests
poetry run python manage.py test
# Run tests with verbose output
poetry run python manage.py test -v 3
# Run a specific test
poetry run python manage.py test app.tests.TestClass.test_methodTest output (last 100 lines)For more information, see the Django testing documentation. |
@copilot please fix thisFAIL: test_regular_user_cannot_access_dashboard (website.tests.test_organization.OrganizationSwitchingTests.test_regular_user_cannot_access_dashboard)
|
… users without organizations Co-authored-by: DonnieBLT <[email protected]>
Fixed in commit 4c23037. The issue was in the test setup - |
❌ Pre-commit checks failedThe pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them: # Install pre-commit if you haven't already
pip install pre-commit
# Run pre-commit on all files
pre-commit run --all-files
# Or run pre-commit on staged files only
pre-commit runAfter running these commands, the pre-commit hooks will automatically fix most issues. 💡 Tip: You can set up pre-commit to run automatically on every commit by running: pre-commit installPre-commit outputFor more information, see the pre-commit documentation. |
❌ Pre-commit checks failedThe pre-commit hooks found issues that need to be fixed. Please run the following commands locally to fix them: # Install pre-commit if you haven't already
pip install pre-commit
# Run pre-commit on all files
pre-commit run --all-files
# Or run pre-commit on staged files only
pre-commit runAfter running these commands, the pre-commit hooks will automatically fix most issues. 💡 Tip: You can set up pre-commit to run automatically on every commit by running: pre-commit installPre-commit outputFor more information, see the pre-commit documentation. |
Allow administrators to switch between organizations in the dashboard
Test Fix - Regular User Access
Fixed: Test
test_regular_user_cannot_access_dashboardnow properly tests a user with no organizationsProblem: The test setup was creating
org3withregular_useras admin, giving them access to an organization. This caused the test to fail because the view returned 200 (showing the organization) instead of 302 (redirecting away).Solution: Changed org3 to not have an admin user initially. The organization is only managed by
manager_user, ensuringregular_usertruly has no organizations to access.Changes in
website/tests/test_organization.py:admin=self.regular_userfrom org3 creationregular_userhas no organizations and the test correctly expects a redirectThis fix ensures:
regular_userhas no organizations (as intended by the test)manager_usercan still manage org3 via managers relationshipadmin_usercannot access org3 (for other tests)Previous Updates
JavaScript Block Fix:
extra_jsblock tocontentblockPerformance Optimization:
Security Fix:
All PR Review Comments Addressed:
Test Coverage
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.