-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix: Various Edge-Case Bugs & Data Issues in modulestore_migrator #37711
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
Changes from all commits
703e98d
983b802
d4707df
f043dd6
aaf6ff4
2178536
16dc4b8
baea60b
ebdb452
98fb819
a5bd255
741d29f
c9c5500
69ed6d0
131be2a
be51064
e004f9b
045e475
c76357d
627ae7d
f660c78
b9991dc
2803119
52485f9
eeaa9f1
e0e320b
167595c
64da92e
88e5ffb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -236,7 +236,7 @@ def get(self, request: Request): | |
| "number": "CPSPR", | ||
| "can_edit": true | ||
| } | ||
| ], } | ||
| ], | ||
| ``` | ||
| """ | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,8 @@ | |
| ) | ||
| from cms.djangoapps.models.settings.course_grading import CourseGradingModel | ||
| from cms.djangoapps.models.settings.course_metadata import CourseMetadata | ||
| from cms.djangoapps.modulestore_migrator.api import get_migration_info | ||
| from cms.djangoapps.modulestore_migrator import api as migrator_api | ||
| from cms.djangoapps.modulestore_migrator.data import ModulestoreMigration | ||
| from common.djangoapps.course_action_state.managers import CourseActionStateItemNotFoundError | ||
| from common.djangoapps.course_action_state.models import CourseRerunState, CourseRerunUIStateManager | ||
| from common.djangoapps.course_modes.models import CourseMode | ||
|
|
@@ -1572,13 +1573,12 @@ def request_response_format_is_json(request, response_format): | |
|
|
||
| def get_library_context(request, request_is_json=False): | ||
| """ | ||
| Utils is used to get context of course home library tab. | ||
| It is used for both DRF and django views. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated this comment, as the django-based legacy libraries listing is gone. |
||
| Utils is used to get context of course home library tab. Returned in DRF view. | ||
| """ | ||
| from cms.djangoapps.contentstore.views.course import ( | ||
| _accessible_libraries_iter, | ||
| _format_library_for_view, | ||
| _get_course_creator_status, | ||
| format_library_for_view, | ||
| get_allowed_organizations, | ||
| get_allowed_organizations_for_libraries, | ||
| user_can_create_organizations, | ||
|
|
@@ -1590,21 +1590,25 @@ def get_library_context(request, request_is_json=False): | |
| user_can_create_library, | ||
| ) | ||
|
|
||
| is_migrated: bool | None # None means: do not filter on is_migrated | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No functional change to this view handler for any of the 2xx happy-path cases. The changes here just make the handler more careful with types and parsing, so that some client errors which would have resulted in 500s are now caught here and returned as 400s with validation messages. |
||
| if (is_migrated_param := request.GET.get('is_migrated')) is not None: | ||
| is_migrated = BooleanField().to_internal_value(is_migrated_param) | ||
| else: | ||
| is_migrated = None | ||
| libraries = list(_accessible_libraries_iter(request.user) if libraries_v1_enabled() else []) | ||
| library_keys = [lib.location.library_key for lib in libraries] | ||
| migration_info = get_migration_info(library_keys) | ||
| is_migrated_filter = request.GET.get('is_migrated', None) | ||
| migration_info: dict[LibraryLocator, ModulestoreMigration | None] = { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than returning whether the library was ever migrated, this REST API now only considers it migrated if there was a successful authoritative migration with (i.e., a migration where This does not change the logic at all for UI users who successfully migrate their library, as the UI always uses
|
||
| lib.id: migrator_api.get_forwarding(lib.id) | ||
| for lib in libraries | ||
| } | ||
| data = { | ||
| 'libraries': [ | ||
| _format_library_for_view( | ||
| format_library_for_view( | ||
| lib, | ||
| request, | ||
| migrated_to=migration_info.get(lib.location.library_key) | ||
| migration=migration_info[lib.id], | ||
| ) | ||
| for lib in libraries | ||
| if is_migrated_filter is None or ( | ||
| BooleanField().to_internal_value(is_migrated_filter) == (lib.location.library_key in migration_info) | ||
| ) | ||
| if is_migrated is None or is_migrated == bool(migration_info[lib.id]) | ||
| ] | ||
| } | ||
|
|
||
|
|
@@ -1713,8 +1717,7 @@ def format_in_process_course_view(uca): | |
|
|
||
| def get_home_context(request, no_course=False): | ||
| """ | ||
| Utils is used to get context of course home. | ||
| It is used for both DRF and django views. | ||
| Utils is used to get context of course home. Returned by DRF view. | ||
| """ | ||
|
|
||
| from cms.djangoapps.contentstore.views.course import ( | ||
|
|
||
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.
not necessary, as the migrator_api creates missing Source objects automatically