Skip to content

Commit ffe6598

Browse files
andrii-hantkovskyiAndrii
andauthored
fix: [AXM-1877] staged content not creating after import create (#2633)
Co-authored-by: Andrii <andrii.hantkovskyi@raccoongang.com>
1 parent 8dd0605 commit ffe6598

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

cms/djangoapps/import_from_modulestore/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def save_model(self, request, obj, form, change):
9696
is_created = not getattr(obj, 'id', None)
9797
super().save_model(request, obj, form, change)
9898
if is_created:
99-
save_legacy_content_to_staged_content_task.apply_async(kwargs={'import_uuid': obj.uuid})
99+
save_legacy_content_to_staged_content_task.delay_on_commit(obj.uuid)
100100

101101
def import_course_to_library_action(self, request, queryset):
102102
"""

cms/djangoapps/import_from_modulestore/api.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
"""
22
API for course to library import.
33
"""
4-
from functools import partial
5-
6-
from django.db import transaction
7-
84
from .models import Import as _Import
95
from .tasks import import_course_staged_content_to_library_task, save_legacy_content_to_staged_content_task
106

@@ -34,13 +30,10 @@ def create_import(source_key, user_id: int, learning_package_id: int) -> _Import
3430
"""
3531
Create a new import task to import a course to a library.
3632
"""
37-
with transaction.atomic():
38-
import_from_modulestore = _Import.objects.create(
39-
source_key=source_key,
40-
target_id=learning_package_id,
41-
user_id=user_id,
42-
)
43-
transaction.on_commit(
44-
partial(save_legacy_content_to_staged_content_task.delay, import_uuid=str(import_from_modulestore.uuid))
45-
)
46-
return import_from_modulestore
33+
import_from_modulestore = _Import.objects.create(
34+
source_key=source_key,
35+
target_id=learning_package_id,
36+
user_id=user_id,
37+
)
38+
save_legacy_content_to_staged_content_task.delay_on_commit(import_from_modulestore.uuid)
39+
return import_from_modulestore

0 commit comments

Comments
 (0)