mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 12:01:14 +00:00
Merge pull request #156 from cthulahoops/duplicate_reviews
Only import reviews if we're importing the book. (Avoid generating du…
This commit is contained in:
commit
6b86bf32cd
2 changed files with 11 additions and 14 deletions
|
@ -29,7 +29,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()
|
||||
|
@ -38,24 +37,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