forked from mirrors/bookwyrm
Link import job to import status and display status on status page.
This commit is contained in:
parent
22b2a95fd3
commit
60dabe442e
5 changed files with 31 additions and 2 deletions
|
@ -42,7 +42,7 @@ def import_data(job_id):
|
||||||
item.fail_reason = "Could not match book on OpenLibrary"
|
item.fail_reason = "Could not match book on OpenLibrary"
|
||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
outgoing.handle_import_books(job.user, results)
|
status = outgoing.handle_import_books(job.user, results)
|
||||||
for item in reviews:
|
for item in reviews:
|
||||||
review_title = "Review of {!r} on Goodreads".format(
|
review_title = "Review of {!r} on Goodreads".format(
|
||||||
item.book.title,
|
item.book.title,
|
||||||
|
@ -54,5 +54,8 @@ def import_data(job_id):
|
||||||
item.review,
|
item.review,
|
||||||
item.rating,
|
item.rating,
|
||||||
)
|
)
|
||||||
|
if status:
|
||||||
|
job.import_status = status
|
||||||
|
job.save()
|
||||||
finally:
|
finally:
|
||||||
create_notification(job.user, 'IMPORT', related_import=job)
|
create_notification(job.user, 'IMPORT', related_import=job)
|
||||||
|
|
19
fedireads/migrations/0034_importjob_import_status.py
Normal file
19
fedireads/migrations/0034_importjob_import_status.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 3.0.3 on 2020-04-22 13:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('fedireads', '0033_auto_20200422_1249'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='importjob',
|
||||||
|
name='import_status',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='fedireads.Status'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -36,6 +36,8 @@ class ImportJob(models.Model):
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
created_date = models.DateTimeField(default=timezone.now)
|
created_date = models.DateTimeField(default=timezone.now)
|
||||||
task_id = models.CharField(max_length=100, null=True)
|
task_id = models.CharField(max_length=100, null=True)
|
||||||
|
import_status = models.ForeignKey(
|
||||||
|
'Status', null=True, on_delete=models.PROTECT)
|
||||||
|
|
||||||
class ImportItem(models.Model):
|
class ImportItem(models.Model):
|
||||||
job = models.ForeignKey(
|
job = models.ForeignKey(
|
||||||
|
|
|
@ -158,7 +158,7 @@ def handle_shelve(user, book, shelf):
|
||||||
activity = activitypub.get_status(status)
|
activity = activitypub.get_status(status)
|
||||||
create_activity = activitypub.get_create(user, activity)
|
create_activity = activitypub.get_create(user, activity)
|
||||||
|
|
||||||
broadcast(user, create_activity, recipients)
|
broadcast(user, create_activity)
|
||||||
|
|
||||||
|
|
||||||
def handle_unshelve(user, book, shelf):
|
def handle_unshelve(user, book, shelf):
|
||||||
|
@ -206,6 +206,7 @@ def handle_import_books(user, items):
|
||||||
create_activity = activitypub.get_create(
|
create_activity = activitypub.get_create(
|
||||||
user, activitypub.get_status(status))
|
user, activitypub.get_status(status))
|
||||||
broadcast(user, create_activity)
|
broadcast(user, create_activity)
|
||||||
|
return status
|
||||||
|
|
||||||
|
|
||||||
def handle_rate(user, book, rating):
|
def handle_rate(user, book, rating):
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
<p>
|
<p>
|
||||||
{{ task.info }}
|
{{ task.info }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if job.import_status %}
|
||||||
|
{% include 'snippets/status.html' with status=job.import_status %}
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
Import still in progress.
|
Import still in progress.
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in a new issue