Skip to content

refactor: split REST API views by domain ownership - #453

Open
mariajgrimaldi wants to merge 2 commits into
MJG/authz-domain-adrsfrom
MJG/rest-api-domain-split
Open

mariajgrimaldi wants to merge 2 commits into
MJG/authz-domain-adrsfrom
MJG/rest-api-domain-split

Conversation

@mariajgrimaldi

@mariajgrimaldi mariajgrimaldi commented Sep 16, 2026

Copy link
Copy Markdown
Member

Description

This PR splits the REST API views and tests by domain ownership, following the boundary recorded in ADR 0016. It changes the package layout without changing the API URLs or endpoint behavior.

The Admin Console endpoints now live under openedx_authz.rest_api.v1.admin_console:

  • AdminConsoleOrgsAPIView
  • ScopesAPIView
  • TeamMembersAPIView
  • TeamMemberAssignmentsAPIView
  • AssignmentsAPIView

Their filters and tests move with them. WaffleFlagStatesAPIView and its tests move under openedx_authz.rest_api.v1.course_authoring. The shared authorization endpoints, including permission validation and role operations, remain in v1/views.py.

This package boundary lets domain-specific behavior stay with the domain that owns it. The course-authoring filter implementation is kept out of this PR and remains in the next layer, #361.

Stack dependency

This PR is stacked on #390, which documents the ownership boundary and cross-domain filter decision. Review and merge #390 first.

Testing

  • 493 focused REST API tests pass under Python 3.12 and Django 5.2.
  • Pylint, Ruff, and pydocstyle pass.
  • The Sphinx documentation build passes with warnings treated as errors.

This is a package-layout refactor. The endpoint URLs and behavior remain unchanged, so no separate manual test is needed.

Merge checklist:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided or not applicable
  • Noted concerns, dependencies, migration issues, deadlines, or tickets

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Sep 16, 2026
@openedx-webhooks

openedx-webhooks commented Sep 16, 2026

Copy link
Copy Markdown

Thanks for the pull request, @mariajgrimaldi!

This repository is currently maintained by @openedx/committers-openedx-authz.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Sep 16, 2026
@mariajgrimaldi mariajgrimaldi changed the title MJG/rest api domain split refactor: split REST API views by domain ownership Sep 16, 2026
@mariajgrimaldi
mariajgrimaldi added this pull request to stack #454 September 16, 2026 14:39
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Sep 17, 2026
@mariajgrimaldi
mariajgrimaldi force-pushed the MJG/rest-api-domain-split branch from c923f1f to 993665b Compare September 18, 2026 11:40
mariajgrimaldi and others added 2 commits September 18, 2026 14:16
Moves the five Admin-Console-shaped endpoints (AdminConsoleOrgsAPIView,
ScopesAPIView, TeamMembersAPIView, TeamMemberAssignmentsAPIView,
AssignmentsAPIView) into a new admin_console/ subpackage, and
WaffleFlagStatesAPIView into a new course_authoring/ subpackage, per
the ownership and layout rules being recorded in ADR 0016 and ADR 0017.
PermissionValidationMeView, RoleUserAPIView, RoleListView, and
UserValidationAPIView remain in views.py as generic Authorization
endpoints, with no reference to any specific consumer's packaging;
that reasoning lives in admin_console/course_authoring's own docstrings
and in ADR 0017. No URLs change; tests move alongside their views.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
pylint 4.0.4/astroid 4.0.4 no longer needs the too-many-positional-arguments
suppression on these test/model signatures, flagging the old comments as
useless-suppression. Also trims trailing blank lines flagged by
trailing-newlines, fixes a line-too-long, and drops an unused import in the
new admin_console test module.

openedx_authz/rest_api/v1/filters.py was left behind, byte-identical and
unreferenced, after admin_console/filters.py replaced it in the package
layout split (ADR 0017).

@BryanttV BryanttV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The refactor looks good! I just have a few comments:

There are some serializers exclusive to admin_console. Could we move them to the corresponding module?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a thought: what if we separate the url lists by domain? For example:

authz_urlpatterns = [...]
admin_console_urlpatterns = [...]
course_authoring_urlpatterns = [...]

urlpatterns = authz_urlpatterns + admin_console_urlpatterns + course_authoring_urlpatterns

I think it makes them easier to differentiate. What do you think?

from openedx_authz.constants import permissions, roles
from openedx_authz.models.scopes import get_content_library_model, get_course_overview_model
from openedx_authz.rest_api.v1.admin_console.views import ScopesAPIView
from openedx_authz.tests.rest_api.test_views import ViewTestMixin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we move the ViewTestMixin class to its own mixins.py module? That way, we wouldn't have to import from test_views, but from mixins instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Split REST API views by domain ownership and package layout

4 participants