|
7 | 7 | from django.core.exceptions import ObjectDoesNotExist |
8 | 8 | from django.core.exceptions import PermissionDenied |
9 | 9 | from django.core.exceptions import SuspiciousOperation |
10 | | -from django.core.management import call_command |
11 | 10 | from django.db import transaction |
12 | 11 | from django.http import HttpResponseBadRequest |
13 | 12 | from django.http import HttpResponseForbidden |
@@ -219,7 +218,7 @@ def api_commit_channel(request): |
219 | 218 | event = generate_update_event( |
220 | 219 | channel_id, |
221 | 220 | 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}, |
223 | 222 | ) |
224 | 223 |
|
225 | 224 | # Mark old staging tree for garbage collection |
@@ -310,10 +309,17 @@ def api_publish_channel(request): |
310 | 309 | channel_id = data["channel_id"] |
311 | 310 | # Ensure that the user has permission to edit this channel. |
312 | 311 | 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) |
314 | 319 | return Response({ |
315 | 320 | "success": True, |
316 | | - "channel": channel_id |
| 321 | + "channel": channel_id, |
| 322 | + "task_id": task_info.task_id, |
317 | 323 | }) |
318 | 324 | except (KeyError, Channel.DoesNotExist): |
319 | 325 | return HttpResponseNotFound("No channel matching: {}".format(data)) |
@@ -441,7 +447,7 @@ def get_channel_status_bulk(request): |
441 | 447 | raise PermissionDenied() |
442 | 448 | statuses = {cid: get_status(cid) for cid in data['channel_ids']} |
443 | 449 |
|
444 | | - return Response({"success": True, "statuses": statuses,}) |
| 450 | + return Response({"success": True, "statuses": statuses}) |
445 | 451 | except (Channel.DoesNotExist, PermissionDenied): |
446 | 452 | return HttpResponseNotFound( |
447 | 453 | "No complete set of channels matching: {}".format(",".join(channel_ids)) |
|
0 commit comments