-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Backend for Migrating Legacy Libraries (wip)
- Loading branch information
1 parent
d82aada
commit 2d66c67
Showing
9 changed files
with
554 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
49 changes: 49 additions & 0 deletions
49
openedx/core/djangoapps/content_libraries/management/commands/migrate_legacy_library.py
This file contains 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,49 @@ | ||
""" | ||
Implements ./manage.py cms migrate_legacy_library | ||
""" | ||
import logging | ||
|
||
from django.contrib.auth.models import User # pylint: disable=imported-auth-user | ||
from django.core.management import BaseCommand | ||
|
||
from opaque_keys.edx.locator import LibraryLocator, LibraryLocatorV2 | ||
from openedx.core.djangoapps.content_libraries.migration_api import migrate_legacy_library | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
@TODO | ||
""" | ||
|
||
def add_arguments(self, parser): | ||
""" | ||
Add arguments to the argument parser. | ||
""" | ||
parser.add_argument( | ||
'legacy_library', | ||
type=LibraryLocator.from_string, | ||
) | ||
parser.add_argument( | ||
'new_library', | ||
type=LibraryLocatorV2.from_string, | ||
) | ||
parser.add_argument( | ||
'collection', | ||
type=str, | ||
) | ||
|
||
def handle( # pylint: disable=arguments-differ | ||
self, | ||
legacy_library: LibraryLocator, | ||
new_library: LibraryLocatorV2, | ||
collection: str | None, | ||
**kwargs, | ||
) -> None: | ||
""" | ||
Handle the command. | ||
""" | ||
user = User.objects.filter(is_superuser=True)[0] | ||
migrate_legacy_library(legacy_library, new_library, collection_slug=collection, user=user) |
Oops, something went wrong.