-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: Import from modulestore APIs #36540
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
Merged
kdmccormick
merged 27 commits into
openedx:master
from
raccoongang:NiedielnitsevIvan/feat/import-from-modulestore-apis
Apr 23, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
958b903
feat: create import client
NiedielnitsevIvan 4213966
feat: create celery tasks for import functionality
NiedielnitsevIvan c03dcd8
feat: add python APIs to create and process import
NiedielnitsevIvan a3ea142
style: fix pylint issues
NiedielnitsevIvan 9acd085
test: add tests
NiedielnitsevIvan ff2903d
refactor: fix after rebase
NiedielnitsevIvan cbfe82d
refactor: fix after changed relations in the import models
NiedielnitsevIvan 60de98a
test: update tests
NiedielnitsevIvan ee3f843
style: remove extra imports
NiedielnitsevIvan 3e31032
refactor: signal logic moved to the seprate util
NiedielnitsevIvan 359b2bc
refactor: rename purpose
NiedielnitsevIvan 9abe4fc
refactor: rename APIs
NiedielnitsevIvan 3aa550e
test: avoid using factories for content_library (#2635)
cmltaWt0 15fe9e5
refactor: refactor CompositionLevel enum
NiedielnitsevIvan 5ff0620
fix: fix logic for not yet supported composition levels
NiedielnitsevIvan 8cce09b
fix: comment tests for not yet supported composition levels
NiedielnitsevIvan 9112822
refactor: fix issues after review
NiedielnitsevIvan 5f6a1e5
feat: adding support for importing sections and subsections
NiedielnitsevIvan 852a243
test: fix tests after refactoring
NiedielnitsevIvan 9b96363
style: fix naming and add type hints
NiedielnitsevIvan 227230b
chore: add cms/djangoapps/import_from_modulestore to mypy.ini
NiedielnitsevIvan 2761d16
refactor: refactor Composition Levels
NiedielnitsevIvan a5595f2
refactor: improve static typization to fix mypy errors
51658aa
refactor: fix StagedContent import to prevent lint error
be631da
refactor: fix pylint error for error raising
9a881d8
Merge branch 'master' into NiedielnitsevIvan/feat/import-from-modules…
NiedielnitsevIvan c49cdae
refactor: improve Import client container mapps
NiedielnitsevIvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """ | ||
| API for course to library import. | ||
| """ | ||
| from typing import Sequence | ||
|
|
||
| from opaque_keys.edx.keys import LearningContextKey, UsageKey | ||
|
|
||
| from .helpers import cancel_incomplete_old_imports | ||
| from .models import Import as _Import | ||
| from .tasks import import_staged_content_to_library_task, save_legacy_content_to_staged_content_task | ||
| from .validators import validate_usage_keys_to_import | ||
|
|
||
|
|
||
| def stage_content_for_import(source_key: LearningContextKey, user_id: int) -> _Import: | ||
| """ | ||
| Create a new import event to import a course to a library and save course to staged content. | ||
| """ | ||
| import_from_modulestore = _Import.objects.create(source_key=source_key, user_id=user_id) | ||
| cancel_incomplete_old_imports(import_from_modulestore) | ||
| save_legacy_content_to_staged_content_task.delay_on_commit(import_from_modulestore.uuid) | ||
| return import_from_modulestore | ||
|
|
||
|
|
||
| def import_staged_content_to_library( | ||
| usage_ids: Sequence[str | UsageKey], | ||
| import_uuid: str, | ||
| target_learning_package_id: int, | ||
| user_id: int, | ||
| composition_level: str, | ||
| override: bool, | ||
| ) -> None: | ||
| """ | ||
| Import staged content to a library from staged content. | ||
| """ | ||
| validate_usage_keys_to_import(usage_ids) | ||
| import_staged_content_to_library_task.apply_async( | ||
| kwargs={ | ||
| 'usage_key_strings': usage_ids, | ||
| 'import_uuid': import_uuid, | ||
| 'learning_package_id': target_learning_package_id, | ||
| 'user_id': user_id, | ||
| 'composition_level': composition_level, | ||
| 'override': override, | ||
| }, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| """ | ||
| Constants for import_from_modulestore app | ||
| """ | ||
|
|
||
| IMPORT_FROM_MODULESTORE_STAGING_PURPOSE = "import_from_modulestore" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks for adding so many type annotations! Please add cms/djangoapps/import_from_modulestore to
mypy.iniso that they will be checked when mypy is executed.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.
Added, and type annotations have been improved a bit more.