Skip to content

Commit

Permalink
feat: create upstream links after course import
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Jan 17, 2025
1 parent 02a8a82 commit 60b4f43
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion xmodule/modulestore/xml_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
from xblock.runtime import DictKeyValueStore, KvsFieldData

from common.djangoapps.util.monitoring import monitor_import_failure
from openedx.core.djangoapps.content_libraries.tasks import create_or_update_upstream_links
from openedx.core.djangoapps.content_tagging.api import import_course_tags_from_csv
from xmodule.assetstore import AssetMetadata
from xmodule.contentstore.content import StaticContent
from xmodule.errortracker import make_error_tracker
Expand All @@ -52,7 +54,6 @@
from xmodule.tabs import CourseTabList
from xmodule.util.misc import escape_invalid_characters
from xmodule.x_module import XModuleMixin
from openedx.core.djangoapps.content_tagging.api import import_course_tags_from_csv

from .inheritance import own_metadata
from .store_utilities import rewrite_nonportable_content_links
Expand Down Expand Up @@ -548,6 +549,11 @@ def depth_first(subtree):
# pylint: disable=raise-missing-from
raise BlockFailedToImport(leftover.display_name, leftover.location)

def post_course_import(self, dest_id):
"""
Tasks that need to triggered after a course is imported.
"""

def run_imports(self):
"""
Iterate over the given directories and yield courses.
Expand Down Expand Up @@ -589,6 +595,7 @@ def run_imports(self):
logging.info(f'Course import {dest_id}: No tags.csv file present.')
except ValueError as e:
logging.info(f'Course import {dest_id}: {str(e)}')
self.post_course_import(dest_id)
yield courselike


Expand Down Expand Up @@ -717,6 +724,12 @@ def import_tags(self, data_path, dest_id):
csv_path = path(data_path) / 'tags.csv'
import_course_tags_from_csv(csv_path, dest_id)

def post_course_import(self, dest_id):
"""
Trigger celery task to create upstream links for newly imported blocks.
"""
create_or_update_upstream_links.delay(str(dest_id))


class LibraryImportManager(ImportManager):
"""
Expand Down

0 comments on commit 60b4f43

Please sign in to comment.