Don't double-add readthroughs in re-import

This commit is contained in:
Mouse Reeve
2021-01-10 09:36:11 -08:00
parent a1e8d5c7c2
commit b1b40e3c98
2 changed files with 38 additions and 0 deletions

View File

@ -180,6 +180,13 @@ def handle_imported_book(user, item, include_reviews, privacy):
broadcast(user, shelf_book.to_add_activity(user), privacy=privacy)
for read in item.reads:
# check for an existing readthrough with the same dates
if models.ReadThrough.objects.filter(
user=user, book=item.book,
start_date=read.start_date,
finish_date=read.finish_date
).exists():
continue
read.book = item.book
read.user = user
read.save()