mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 16:40:36 +00:00
Mark imports as complete
This will let the user debug the import, and should only be used when the import is in a bad state (marked as incomplete but with no pending tasks)
This commit is contained in:
parent
6eab1fdd6d
commit
a8424f61f2
5 changed files with 54 additions and 2 deletions
|
@ -53,6 +53,7 @@ class ImportJob(models.Model):
|
|||
"""How many books do you want to import???"""
|
||||
return self.items.count()
|
||||
|
||||
@property
|
||||
def pending_item_count(self):
|
||||
"""And how many pending items??"""
|
||||
return self.pending_items.count()
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
{% extends 'components/modal.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block modal-title %}{% trans "Mark import as complete?" %}{% endblock %}
|
||||
|
||||
{% block modal-body %}
|
||||
{% trans "This action cannot be un-done" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block modal-footer %}
|
||||
<form name="complete-import-{{ import.id }}" action="{% url 'settings-imports-complete' import.id %}" method="POST" class="is-flex-grow-1">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id" value="{{ list.id }}">
|
||||
<div class="buttons is-right is-flex-grow-1">
|
||||
<button type="button" class="button" data-modal-close>
|
||||
{% trans "Cancel" %}
|
||||
</button>
|
||||
<button class="button is-danger" type="submit">
|
||||
{% trans "Confirm" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -26,9 +26,11 @@
|
|||
</div>
|
||||
|
||||
<div class="table-container block content">
|
||||
{% if status == "active" %}
|
||||
<div class="notification is-warning">
|
||||
<p>{% trans "Marking an import as complete will <em>not</em> stop it." %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table is-striped is-fullwidth">
|
||||
<tr>
|
||||
{% url 'settings-imports' as url %}
|
||||
|
@ -47,7 +49,9 @@
|
|||
<th>
|
||||
{% trans "Pending items" %}
|
||||
</th>
|
||||
{% if status == "active" %}
|
||||
<th>{% trans "Actions" %}</th>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% for import in imports %}
|
||||
<tr>
|
||||
|
@ -58,11 +62,22 @@
|
|||
<td>{{ import.created_date }}</td>
|
||||
<td>{{ import.item_count }}</td>
|
||||
<td>{{ import.pending_item_count }}</td>
|
||||
{% if status == "active" %}
|
||||
<td>
|
||||
<button class="button is-danger">{% trans "Mark as complete" %}</button>
|
||||
{% join "complete" import.id as modal_id %}
|
||||
<button type="button" data-modal-open="{{ modal_id }}" class="button is-danger">{% trans "Mark as complete" %}</button>
|
||||
{% include "settings/imports/complete_import_modal.html" with id=modal_id %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% if not imports %}
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<em>{% trans "No matching imports founds." %} </em>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -294,6 +294,9 @@ urlpatterns = [
|
|||
re_path(
|
||||
r"^settings/imports/(?P<status>(complete|active))?/?$", views.ImportList.as_view(), name="settings-imports"
|
||||
),
|
||||
re_path(
|
||||
r"^settings/imports/(?P<import_id>\d+)/complete?$", views.ImportList.as_view(), name="settings-imports-complete"
|
||||
),
|
||||
re_path(
|
||||
r"^settings/celery/?$", views.CeleryStatus.as_view(), name="settings-celery"
|
||||
),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
""" manage imports """
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
|
@ -29,5 +30,14 @@ class ImportList(View):
|
|||
"page_range": paginated.get_elided_page_range(
|
||||
page.number, on_each_side=2, on_ends=1
|
||||
),
|
||||
"status": status,
|
||||
}
|
||||
return TemplateResponse(request, "settings/imports.html", data)
|
||||
return TemplateResponse(request, "settings/imports/imports.html", data)
|
||||
|
||||
# pylint: disable=unused-argument
|
||||
def post(self, request, import_id):
|
||||
"""Mark an import as complete"""
|
||||
import_job = get_object_or_404(models.ImportJob, id=import_id)
|
||||
import_job.complete = True
|
||||
import_job.save()
|
||||
return redirect("settings-imports")
|
||||
|
|
Loading…
Reference in a new issue