Skip to content

Commit 880b79a

Browse files
authored
Add SCIM endpoints (#2619)
1 parent 5aee7df commit 880b79a

File tree

13 files changed

+264
-15
lines changed

13 files changed

+264
-15
lines changed

cms/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def get_wagtail_img_src(image_obj) -> str:
255255

256256

257257
def create_default_courseware_page(
258-
courseware: Union[Course, Program], # noqa: FA100
258+
courseware: Union[Course, Program],
259259
live: bool = False, # noqa: FBT001, FBT002
260260
*args, # noqa: ARG001
261261
**kwargs, # noqa: ARG001

courses/management/commands/create_courseware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Command(BaseCommand):
2121

2222
def _check_if_courseware_object_readable_id_exists(
2323
self,
24-
courseware_object: Union[Course, Program], # noqa: FA100
24+
courseware_object: Union[Course, Program],
2525
courseware_id: str,
2626
):
2727
"""
@@ -44,7 +44,7 @@ def _check_if_courseware_object_readable_id_exists(
4444

4545
def _add_departments_to_courseware_object(
4646
self,
47-
courseware_object: Union[Course, Program], # noqa: FA100
47+
courseware_object: Union[Course, Program],
4848
departments: models.QuerySet,
4949
):
5050
"""
@@ -110,7 +110,7 @@ def _departments_do_not_exist_error(self):
110110

111111
def _successfully_created_courseware_object_message(
112112
self,
113-
courseware_object: Union[Course, Program], # noqa: FA100
113+
courseware_object: Union[Course, Program],
114114
):
115115
"""
116116
Outputs a success message to the console in the format of

courses/views/v1/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def get_serializer_context(self):
253253

254254
def _validate_enrollment_post_request(
255255
request: Request,
256-
) -> Union[Tuple[Optional[HttpResponse], None, None], Tuple[None, User, CourseRun]]: # noqa: FA100, UP006
256+
) -> Union[Tuple[Optional[HttpResponse], None, None], Tuple[None, User, CourseRun]]: # noqa: UP006
257257
"""
258258
Validates a request to create an enrollment. Returns a response if validation fails, or a user and course run
259259
if validation succeeds.

flexiblepricing/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def update_currency_exchange_rate(rates, currency_descriptions):
363363

364364

365365
def create_default_flexible_pricing_page(
366-
object: Union[Course, Program], # noqa: A002, FA100
366+
object: Union[Course, Program], # noqa: A002
367367
forceCourse: bool = False, # noqa: FBT001, FBT002
368368
*args, # noqa: ARG001
369369
**kwargs,

main/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def exception_handler(exc, context):
77
"""Override DRF exception_handler to slightly change format of error response"""
88
if isinstance(exc, exceptions.ValidationError) and isinstance(
9-
exc.detail, (list, dict)
9+
exc.detail, list | dict
1010
):
1111
exc = exceptions.ValidationError(
1212
detail={"errors": exc.detail}, code=exc.status_code

main/settings.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from mitol.google_sheets.settings.google_sheets import * # noqa: F403
2626
from mitol.google_sheets_deferrals.settings.google_sheets_deferrals import * # noqa: F403
2727
from mitol.google_sheets_refunds.settings.google_sheets_refunds import * # noqa: F403
28+
from mitol.scim.settings.scim import * # noqa: F403
2829
from redbeat import RedBeatScheduler
2930

3031
from main.celery_utils import OffsettingSchedule
@@ -214,6 +215,7 @@
214215
"mitol.authentication.apps.TransitionalAuthenticationApp",
215216
"mitol.payment_gateway.apps.PaymentGatewayApp",
216217
"mitol.olposthog.apps.OlPosthog",
218+
"mitol.scim.apps.ScimApp",
217219
# "mitol.oauth_toolkit_extensions.apps.OAuthToolkitExtensionsApp",
218220
"viewflow",
219221
"openapi",
@@ -495,7 +497,10 @@
495497
]
496498
for name, path in [
497499
("mitx-online", os.path.join(BASE_DIR, "frontend/public/build")), # noqa: PTH118
498-
("staff-dashboard", os.path.join(BASE_DIR, "frontend/staff-dashboard/build")), # noqa: PTH118
500+
(
501+
"staff-dashboard",
502+
os.path.join(BASE_DIR, "frontend/staff-dashboard/build"), # noqa: PTH118
503+
),
499504
]:
500505
if os.path.exists(path): # noqa: PTH110
501506
STATICFILES_DIRS.append((name, path))
@@ -994,6 +999,8 @@
994999
),
9951000
}
9961001

1002+
SCIM_SERVICE_PROVIDER["USER_ADAPTER"] = "users.adapters.LearnUserAdapter" # noqa: F405
1003+
9971004

9981005
# DRF configuration
9991006
REST_FRAMEWORK = {

main/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class MockResponse:
5454
def __init__(
5555
self, content, status_code=200, content_type="application/json", url=None
5656
):
57-
if isinstance(content, (dict, list)):
57+
if isinstance(content, dict | list):
5858
self.content = json.dumps(content)
5959
else:
6060
self.content = str(content)

main/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
path("", include("flexiblepricing.urls")),
5050
path("", include("mitol.google_sheets.urls")),
5151
path("", include("b2b.urls")),
52+
re_path(r"", include("mitol.scim.urls")),
5253
re_path(r"^dashboard/", index, name="user-dashboard"),
5354
# social django needs to be here to preempt the login
5455
path("", include("social_django.urls", namespace="social")),

poetry.lock

Lines changed: 84 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ drf-spectacular = "^0.28.0"
7171
wagtail = "6.3"
7272
mitol-django-apigateway = "^2025.4.25.1"
7373
rich = "^14.0.0"
74+
pyparsing = "^3.2"
75+
mitol-django-scim = "^2025.3.31"
7476

7577

7678
[tool.poetry.group.dev.dependencies]
@@ -98,7 +100,7 @@ wagtail-factories = "^4.2"
98100
pytest-xdist = {extras = ["psutil"], version = "^3.6.1"}
99101

100102
[tool.ruff]
101-
target-version = "py39"
103+
target-version = "py310"
102104
line-length = 88
103105

104106
[tool.ruff.lint]

0 commit comments

Comments
 (0)