mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
adds button to stop job
This commit is contained in:
parent
7a36de5ebe
commit
6792b3d7b8
4 changed files with 16 additions and 4 deletions
|
@ -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 %}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue