forked from mirrors/bookwyrm
Associate imported review with import item
This commit is contained in:
parent
1e2dca402b
commit
1e46de4c9d
4 changed files with 35 additions and 0 deletions
|
@ -205,3 +205,5 @@ def handle_imported_book(item):
|
||||||
)
|
)
|
||||||
# only broadcast this review to other bookwyrm instances
|
# only broadcast this review to other bookwyrm instances
|
||||||
review.save(software="bookwyrm", priority=LOW)
|
review.save(software="bookwyrm", priority=LOW)
|
||||||
|
item.linked_review = review
|
||||||
|
item.save()
|
||||||
|
|
24
bookwyrm/migrations/0115_importitem_linked_review.py
Normal file
24
bookwyrm/migrations/0115_importitem_linked_review.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Generated by Django 3.2.5 on 2021-11-13 19:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bookwyrm", "0114_importjob_source"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="importitem",
|
||||||
|
name="linked_review",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
to="bookwyrm.review",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -60,6 +60,9 @@ class ImportItem(models.Model):
|
||||||
related_name="book_guess",
|
related_name="book_guess",
|
||||||
)
|
)
|
||||||
fail_reason = models.TextField(null=True)
|
fail_reason = models.TextField(null=True)
|
||||||
|
linked_review = models.ForeignKey(
|
||||||
|
"Review", on_delete=models.SET_NULL, null=True, blank=True
|
||||||
|
)
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self):
|
||||||
"""try various ways to lookup a book"""
|
"""try various ways to lookup a book"""
|
||||||
|
|
|
@ -233,6 +233,9 @@ class GenericImporter(TestCase):
|
||||||
self.assertEqual(review.rating, 2.0)
|
self.assertEqual(review.rating, 2.0)
|
||||||
self.assertEqual(review.privacy, "unlisted")
|
self.assertEqual(review.privacy, "unlisted")
|
||||||
|
|
||||||
|
import_item.refresh_from_db()
|
||||||
|
self.assertEqual(import_item.linked_review, review)
|
||||||
|
|
||||||
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
@patch("bookwyrm.activitystreams.add_status_task.delay")
|
||||||
def test_handle_imported_book_rating(self, *_):
|
def test_handle_imported_book_rating(self, *_):
|
||||||
"""rating import"""
|
"""rating import"""
|
||||||
|
@ -250,6 +253,9 @@ class GenericImporter(TestCase):
|
||||||
self.assertEqual(review.rating, 3.0)
|
self.assertEqual(review.rating, 3.0)
|
||||||
self.assertEqual(review.privacy, "unlisted")
|
self.assertEqual(review.privacy, "unlisted")
|
||||||
|
|
||||||
|
import_item.refresh_from_db()
|
||||||
|
self.assertEqual(import_item.linked_review.id, review.id)
|
||||||
|
|
||||||
def test_handle_imported_book_reviews_disabled(self, *_):
|
def test_handle_imported_book_reviews_disabled(self, *_):
|
||||||
"""review import"""
|
"""review import"""
|
||||||
import_job = self.importer.create_job(
|
import_job = self.importer.create_job(
|
||||||
|
|
Loading…
Reference in a new issue