Feature organization model - #6080
Conversation
|
👋 Hi @nairaj2, thanks for contributing! For the review process to begin, please verify that the following is satisfied:
Also check that issue requirements are satisfied & you ran Pull requests that don't follow the guidelines will be closed. Reviewer assignment can take up to 2 weeks. |
🔵 Review postedLast updated: 2026-08-04 18:38 UTC |
|
📢✨ Before we assign a reviewer, we'll turn on |
rtibblesbot
left a comment
There was a problem hiding this comment.
PR #6080 — blockers inline; newest commits unreviewed.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
Ran a phased review pipeline over the pull request diff:
- Classified the diff to select review passes (core, frontend, backend) and whether manual QA was required
- Core review pass checked correctness, design, architecture, testing, completeness, and DRY/SRP/Rule-of-Three principles
- Specialized frontend/backend review passes applied framework-specific lenses where those files changed
- For UI changes: manual QA and an accessibility audit against a live dev server, when available
- Checked CI status and linked issue acceptance criteria
- Synthesized one review from those passes and chose the verdict from the findings, CI status, and QA evidence
| class OrganizationMemberSerializer(BulkModelSerializer): | ||
| """ | ||
| Write serializer for updating OrganizationRole membership records. | ||
|
|
There was a problem hiding this comment.
blocking: no create route; Invitation.accept() (models.py:3738) is channel-only. Sole OrganizationRole writer: perform_create (179). #5967 membership/roles unmet.
| def _is_site_admin(user): | ||
| return bool(getattr(user, "is_admin", False)) | ||
|
|
||
|
|
There was a problem hiding this comment.
blocking: Channel.filter_edit_queryset/filter_view_queryset (models.py:1216, 1235) ignore OrganizationRole — no Channel.organization access (#5967). Add Exists(OrganizationRole).
| from rest_framework import serializers | ||
| from rest_framework.exceptions import PermissionDenied | ||
| from rest_framework.exceptions import ValidationError | ||
| from rest_framework.permissions import IsAuthenticated |
There was a problem hiding this comment.
blocking: pre-commit fails on head (reorder-python-imports, black); Linting job fails.
|
|
||
|
|
||
| class OrganizationMemberFilter(FilterSet): | ||
| organization = CharFilter(field_name="organization_id") |
There was a problem hiding this comment.
blocking: User.id is an integer PK; ?user=abc → 500 (reproduced). Use NumberFilter, UUIDFilter.
| raise ValidationError( | ||
| "An organization must have at least one active admin." | ||
| ) | ||
|
|
There was a problem hiding this comment.
blocking: serialize_object() re-reads get_queryset() (251, active-only): self-deactivation commits, then 404s (reproduced).
| "created_at", | ||
| "updated_at", | ||
| ) | ||
|
|
There was a problem hiding this comment.
suggestion: model-level filter_view_queryset/filter_edit_queryset (base.py:585-599); repeated at 162, 274, 293; _require_admin unreachable.
|
|
||
| def perform_update(self, serializer): | ||
| with transaction.atomic(): | ||
| membership = ( |
There was a problem hiding this comment.
suggestion: select_for_update(of=("self",)); lock order against 334 deadlocks.
|
|
||
|
|
||
| class OrganizationAPITestCase(BaseAPITestCase): | ||
| """Shared organization API fixtures and URL helpers.""" |
There was a problem hiding this comment.
suggestion: convention: tests/viewsets/ + StudioAPITestCase. BaseAPITestCase.setUp adds an unused channel tree.
| raise PermissionDenied( | ||
| "Only active organization admins may manage membership." | ||
| ) | ||
|
|
There was a problem hiding this comment.
praise: covers demotion, deactivation, deletion; locked in-transaction; tested.
Summary
Adds backend API and controller support for the Organization and OrganizationRole models.
This change provides:
Organization administrators can manage organization settings, memberships, and roles. Editors can view memberships but cannot manage organization settings, memberships, or roles. Viewers have read-only access to organization resources.
Frontend changes and data model changes are outside the scope of this PR.
…
References
References
Closes #5967
Builds on #5962
…
Reviewer guidance
Run the organization API tests with:
pytest -q contentcuration/contentcuration/tests/test_organization.py
Reviewers can verify that:
This PR does not include frontend changes.
…
AI usage
Used AI to help review the existing Studio API patterns and draft portions of the organization viewsets and tests.
I reviewed and edited the generated code to align it with Studio's ValuesViewset, serializer, routing, pagination, and permission conventions. I also ran the organization tests locally and used the failures to correct routing, response formatting, authentication expectations, and role-permission behavior.