From d04271af7596fde06bbd8d0927be7e096e1d9d13 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 7 Jan 2021 08:08:12 -0800 Subject: [PATCH] Adds field on import job to check if job completed the task isn't a reliable indicator, unfortunately. --- bookwyrm/goodreads_import.py | 2 ++ bookwyrm/migrations/0034_importjob_complete.py | 18 ++++++++++++++++++ bookwyrm/models/import_job.py | 1 + bookwyrm/templates/import_status.html | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/migrations/0034_importjob_complete.py diff --git a/bookwyrm/goodreads_import.py b/bookwyrm/goodreads_import.py index 9b8a4f019..5c982764b 100644 --- a/bookwyrm/goodreads_import.py +++ b/bookwyrm/goodreads_import.py @@ -69,3 +69,5 @@ def import_data(job_id): item.save() finally: create_notification(job.user, 'IMPORT', related_import=job) + job.complete = True + job.save() diff --git a/bookwyrm/migrations/0034_importjob_complete.py b/bookwyrm/migrations/0034_importjob_complete.py new file mode 100644 index 000000000..141706070 --- /dev/null +++ b/bookwyrm/migrations/0034_importjob_complete.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2021-01-07 16:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0033_siteinvite_created_date'), + ] + + operations = [ + migrations.AddField( + model_name='importjob', + name='complete', + field=models.BooleanField(default=False), + ), + ] diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py index 1ebe9b31b..b10651b96 100644 --- a/bookwyrm/models/import_job.py +++ b/bookwyrm/models/import_job.py @@ -42,6 +42,7 @@ class ImportJob(models.Model): created_date = models.DateTimeField(default=timezone.now) task_id = models.CharField(max_length=100, null=True) include_reviews = models.BooleanField(default=True) + complete = models.BooleanField(default=False) privacy = models.CharField( max_length=255, default='public', diff --git a/bookwyrm/templates/import_status.html b/bookwyrm/templates/import_status.html index 6bb903b00..077cd3fbb 100644 --- a/bookwyrm/templates/import_status.html +++ b/bookwyrm/templates/import_status.html @@ -8,7 +8,7 @@

Import started: {{ job.created_date | naturaltime }}

- {% if task.successful %} + {% if job.complete %}

Import completed: {{ task.date_done | naturaltime }}