Start and stop jobs from the model
This commit is contained in:
parent
97513a43d6
commit
7a36de5ebe
6 changed files with 183 additions and 145 deletions
|
@ -97,6 +97,6 @@ class Import(View):
|
|||
except (UnicodeDecodeError, ValueError, KeyError):
|
||||
return HttpResponseBadRequest(_("Not a valid csv file"))
|
||||
|
||||
importer.start_import(job)
|
||||
job.start_job()
|
||||
|
||||
return redirect(f"/import/{job.id}")
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.views.decorators.http import require_POST
|
|||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.importers import GoodreadsImporter
|
||||
from bookwyrm.importers.importer import import_item_task
|
||||
from bookwyrm.models.import_job import import_item_task
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
|
@ -74,3 +74,12 @@ def retry_item(request, job_id, item_id):
|
|||
)
|
||||
import_item_task.delay(item.id)
|
||||
return redirect("import-status", job_id)
|
||||
|
||||
|
||||
@login_required
|
||||
@require_POST
|
||||
def cancel_import(request, job_id):
|
||||
"""scrap that"""
|
||||
job = get_object_or_404(models.ImportJob, id=job_id, job__user=request.user)
|
||||
job.stop()
|
||||
return redirect("import-status", job_id)
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.views import View
|
|||
from django.views.decorators.http import require_POST
|
||||
|
||||
from bookwyrm import models
|
||||
from bookwyrm.importers.importer import import_item_task
|
||||
from bookwyrm.models.import_job import import_item_task
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
|
|
|
@ -52,5 +52,5 @@ class ImportTroubleshoot(View):
|
|||
job,
|
||||
items,
|
||||
)
|
||||
importer.start_import(job)
|
||||
job.start_job()
|
||||
return redirect(f"/import/{job.id}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue