From b2a4066bce188c988e7d275143eeb491cabd4590 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 14 Nov 2024 11:20:23 -0500 Subject: [PATCH] feat!: Remove the import command from the lms. This used to be a symlink that then turned into a copy of the same command that exists in the contentstore in the CMS. That command is the correct one to use, this one is going to be removed to reduce confusion. BREAKING CHANGE: The `python manage.py lms import` command will no longer work. Use the `python manage.py cms import` command instead. --- .../courseware/management/commands/import.py | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 lms/djangoapps/courseware/management/commands/import.py diff --git a/lms/djangoapps/courseware/management/commands/import.py b/lms/djangoapps/courseware/management/commands/import.py deleted file mode 100644 index 7ebb26795112..000000000000 --- a/lms/djangoapps/courseware/management/commands/import.py +++ /dev/null @@ -1,78 +0,0 @@ -""" -Script for importing courseware from XML format -""" - - -from django.core.management.base import BaseCommand - -from openedx.core.djangoapps.django_comment_common.utils import are_permissions_roles_seeded, seed_permissions_roles -from xmodule.contentstore.django import contentstore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore import ModuleStoreEnum # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.django import modulestore # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.modulestore.xml_importer import import_course_from_xml # lint-amnesty, pylint: disable=wrong-import-order -from xmodule.util.sandboxing import DEFAULT_PYTHON_LIB_FILENAME # lint-amnesty, pylint: disable=wrong-import-order - - -class Command(BaseCommand): - """ - Import the specified data directory into the default ModuleStore - """ - help = 'Import the specified data directory into the default ModuleStore.' - - def add_arguments(self, parser): - parser.add_argument('data_directory') - parser.add_argument('course_dirs', - nargs='*', - metavar='course_dir') - parser.add_argument('--nostatic', - action='store_true', - help='Skip import of static content') - parser.add_argument('--nopythonlib', - action='store_true', - help=( - 'Skip import of course python library if it exists ' - '(NOTE: If the static content import is not skipped, the python library ' - 'will be imported and this flag will be ignored)' - )) - parser.add_argument('--python-lib-filename', - default=DEFAULT_PYTHON_LIB_FILENAME, - help='Filename of the course code library (if it exists)') - - def handle(self, *args, **options): - data_dir = options['data_directory'] - source_dirs = options['course_dirs'] - if not source_dirs: - source_dirs = None - do_import_static = not options.get('nostatic', False) - # If the static content is not skipped, the python lib should be imported regardless - # of the 'nopythonlib' flag. - do_import_python_lib = do_import_static or not options.get('nopythonlib', False) - python_lib_filename = options.get('python_lib_filename') - - output = ( - "Importing...\n" - " data_dir={data}, source_dirs={courses}\n" - " Importing static content? {import_static}\n" - " Importing python lib? {import_python_lib}" - ).format( - data=data_dir, - courses=source_dirs, - import_static=do_import_static, - import_python_lib=do_import_python_lib - ) - self.stdout.write(output) - mstore = modulestore() - - course_items = import_course_from_xml( - mstore, ModuleStoreEnum.UserID.mgmt_command, data_dir, source_dirs, load_error_blocks=False, - static_content_store=contentstore(), verbose=True, - do_import_static=do_import_static, do_import_python_lib=do_import_python_lib, - create_if_not_present=True, - python_lib_filename=python_lib_filename, - ) - - for course in course_items: - course_id = course.id - if not are_permissions_roles_seeded(course_id): - self.stdout.write(f'Seeding forum roles for course {course_id}\n') - seed_permissions_roles(course_id)