1
0
Fork 0

Merge pull request #150 from cthulahoops/async_import

Async import
This commit is contained in:
Mouse Reeve 2020-04-27 10:15:43 -07:00 committed by GitHub
commit 4f9edae05a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 423 additions and 174 deletions

View file

@ -1,4 +1,5 @@
{% extends 'layout.html' %}
{% load humanize %}
{% block content %}
<div class="content-container">
<h2>Import Books from GoodReads</h2>
@ -6,7 +7,13 @@
{% csrf_token %}
{{ import_form.as_p }}
<button type="submit">Import</button>
<small>Hang tight, this may take a minute!</small>
</form>
<h2>Recent Imports</h2>
<ul>
{% for job in jobs %}
<li><a href="/import_status/{{ job.id }}">{{ job.created_date | naturaltime }}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}

View file

@ -1,18 +0,0 @@
{% extends 'layout.html' %}
{% block content %}
<div id="content">
<div>
<h1>The following books could not be imported: </h1>
<ul>
{% for item in failures %}
<li>
{{ item }}
</li>
{% endfor %}
</ul>
<p>{{ success_count }} books imported successfully</p>
</div>
</div>
{% endblock %}

View file

@ -0,0 +1,69 @@
{% extends 'layout.html' %}
{% load fr_display %}
{% load humanize %}
{% block content %}
<div id="content">
<div>
<h1>Import Status</h1>
<p>
Import started: {{ job.created_date | naturaltime }}
<p>
{% if task.ready %}
Import completed: {{ task.date_done | naturaltime }}
{% if task.failed %}
<h3><span style="background-color: #ffaaaa;">TASK FAILED</span></h3>
<p>
{{ task.info }}
{% endif %}
{% if job.import_status %}
{% include 'snippets/status.html' with status=job.import_status %}
{% endif %}
{% else %}
Import still in progress.
<p>
(Hit reload to update!)
{% endif %}
<table>
<tr>
<th>
Book
</th>
<th>
Title
</th>
<th>
Author
</th>
<th>
</th>
</tr>
{% for item in items %}
<tr>
<td>
{% if item.book %}
<a href="{{ item.book.absolute_id }}">
{% include 'snippets/book_cover.html' with book=item.book size='small' %}
</a>
{% endif %}
</td>
<td>
{{ item.data|dict_key:'Title' }}
</td>
<td>
{{ item.data|dict_key:'Author' }}
</td>
<td>
{% if item.book %}✓
{% elif item.fail_reason %}
{{ item.fail_reason }}
{% endif %}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}

View file

@ -14,6 +14,7 @@
{% for notification in notifications %}
<div class="notification{% if notification.id in unread %} unread{% endif %}">
<small class="time-ago">{{ notification.created_date | naturaltime }}</small>
{% if notification.related_user %}
{% include 'snippets/username.html' with user=notification.related_user %}
{% if notification.notification_type == 'FAVORITE' %}
favorited your
@ -36,6 +37,10 @@
{% elif notification.notification_type == 'BOOST' %}
boosted your <a href="{{ notification.related_status.absolute_id}}">status</a>
{% endif %}
{% else %}
your <a href="/import_status/{{ notification.related_import.id }}">import</a> completed.
{% endif %}
</div>
{% endfor %}
{% if not notifications %}