Skip to content

Commit 3ab0c24

Browse files
committed
Remove references to exportchannel management command.
1 parent 298ec36 commit 3ab0c24

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

contentcuration/contentcuration/management/commands/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from contentcuration.utils.db_tools import create_user
2525
from contentcuration.utils.files import duplicate_file
2626
from contentcuration.utils.minio_utils import ensure_storage_bucket_public
27+
from contentcuration.utils.publish import publish_channel
2728

2829
logmodule.basicConfig()
2930
logging = logmodule.getLogger(__name__)
@@ -132,7 +133,7 @@ def handle(self, *args, **options):
132133
node.save()
133134

134135
# Publish
135-
call_command('exportchannel', channel1.pk)
136+
publish_channel(admin.id, channel1.pk)
136137

137138
# Add nodes to clipboard in legacy way
138139
legacy_clipboard_nodes = channel1.main_tree.get_children()

contentcuration/contentcuration/views/internal.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from django.core.exceptions import ObjectDoesNotExist
88
from django.core.exceptions import PermissionDenied
99
from django.core.exceptions import SuspiciousOperation
10-
from django.core.management import call_command
1110
from django.db import transaction
1211
from django.http import HttpResponseBadRequest
1312
from django.http import HttpResponseForbidden
@@ -219,7 +218,7 @@ def api_commit_channel(request):
219218
event = generate_update_event(
220219
channel_id,
221220
CHANNEL,
222-
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id,},
221+
{"root_id": obj.main_tree.id, "staging_root_id": obj.staging_tree.id},
223222
)
224223

225224
# Mark old staging tree for garbage collection
@@ -310,10 +309,17 @@ def api_publish_channel(request):
310309
channel_id = data["channel_id"]
311310
# Ensure that the user has permission to edit this channel.
312311
Channel.get_editable(request.user, channel_id)
313-
call_command("exportchannel", channel_id, user_id=request.user.pk, version_notes=data.get('version_notes'))
312+
task_args = {
313+
"user_id": request.user.pk,
314+
"channel_id": channel_id,
315+
"version_notes": data.get('version_notes'),
316+
}
317+
318+
_, task_info = create_async_task("export-channel", request.user, **task_args)
314319
return Response({
315320
"success": True,
316-
"channel": channel_id
321+
"channel": channel_id,
322+
"task_id": task_info.task_id,
317323
})
318324
except (KeyError, Channel.DoesNotExist):
319325
return HttpResponseNotFound("No channel matching: {}".format(data))
@@ -441,7 +447,7 @@ def get_channel_status_bulk(request):
441447
raise PermissionDenied()
442448
statuses = {cid: get_status(cid) for cid in data['channel_ids']}
443449

444-
return Response({"success": True, "statuses": statuses,})
450+
return Response({"success": True, "statuses": statuses})
445451
except (Channel.DoesNotExist, PermissionDenied):
446452
return HttpResponseNotFound(
447453
"No complete set of channels matching: {}".format(",".join(channel_ids))

0 commit comments

Comments
 (0)