forked from mirrors/bookwyrm
Only import reviews if we're importing the book. (Avoid generating duplicate reviews.)
This commit is contained in:
parent
4f9edae05a
commit
62a3891ecf
2 changed files with 11 additions and 14 deletions
|
@ -27,7 +27,6 @@ def import_data(job_id):
|
|||
job = ImportJob.objects.get(id=job_id)
|
||||
try:
|
||||
results = []
|
||||
reviews = []
|
||||
for item in job.items.all():
|
||||
try:
|
||||
item.resolve()
|
||||
|
@ -36,24 +35,11 @@ def import_data(job_id):
|
|||
if item.book:
|
||||
item.save()
|
||||
results.append(item)
|
||||
if item.rating or item.review:
|
||||
reviews.append(item)
|
||||
else:
|
||||
item.fail_reason = "Could not match book on OpenLibrary"
|
||||
item.save()
|
||||
|
||||
status = outgoing.handle_import_books(job.user, results)
|
||||
for item in reviews:
|
||||
review_title = "Review of {!r} on Goodreads".format(
|
||||
item.book.title,
|
||||
) if item.review else ""
|
||||
outgoing.handle_review(
|
||||
job.user,
|
||||
item.book,
|
||||
review_title,
|
||||
item.review,
|
||||
item.rating,
|
||||
)
|
||||
if status:
|
||||
job.import_status = status
|
||||
job.save()
|
||||
|
|
|
@ -192,6 +192,17 @@ def handle_import_books(user, items):
|
|||
activity = activitypub.get_add(user, item.book, desired_shelf)
|
||||
broadcast(user, activity)
|
||||
|
||||
if item.rating or item.review:
|
||||
review_title = "Review of {!r} on Goodreads".format(
|
||||
item.book.title,
|
||||
) if item.review else ""
|
||||
handle_review(
|
||||
user,
|
||||
item.book,
|
||||
review_title,
|
||||
item.review,
|
||||
item.rating,
|
||||
)
|
||||
for read in item.reads:
|
||||
read.book = item.book
|
||||
read.user = user
|
||||
|
|
Loading…
Reference in a new issue