adds button to stop job

This commit is contained in:
Mouse Reeve 2022-11-05 14:44:09 -07:00
parent 7a36de5ebe
commit 6792b3d7b8
4 changed files with 16 additions and 4 deletions

View file

@ -66,6 +66,13 @@
</div>
{% endif %}
{% if not job.complete %}
<form name="stop-import" action="{% url 'import-stop' job.id %}" method="POST">
{% csrf_token %}
<button class="button is-danger" type="submit">{% trans "Stop import" %}</button>
</form>
{% endif %}
{% if manual_review_count and not legacy %}
<div class="notification">
{% blocktrans trimmed count counter=manual_review_count with display_counter=manual_review_count|intcomma %}

View file

@ -353,6 +353,11 @@ urlpatterns = [
views.ImportStatus.as_view(),
name="import-status",
),
re_path(
r"^import/(?P<job_id>\d+)/stop/?$",
views.stop_import,
name="import-stop",
),
re_path(
r"^import/(?P<job_id>\d+)/retry/(?P<item_id>\d+)/?$",
views.retry_item,

View file

@ -74,7 +74,7 @@ from .shelf.shelf_actions import shelve, unshelve
# csv import
from .imports.import_data import Import
from .imports.import_status import ImportStatus, retry_item
from .imports.import_status import ImportStatus, retry_item, stop_import
from .imports.troubleshoot import ImportTroubleshoot
from .imports.manually_review import (
ImportManualReview,

View file

@ -78,8 +78,8 @@ def retry_item(request, job_id, item_id):
@login_required
@require_POST
def cancel_import(request, job_id):
def stop_import(request, job_id):
"""scrap that"""
job = get_object_or_404(models.ImportJob, id=job_id, job__user=request.user)
job.stop()
job = get_object_or_404(models.ImportJob, id=job_id, user=request.user)
job.stop_job()
return redirect("import-status", job_id)