1
0
Fork 0

csv import and export fixes

Adds shelved and published dates for books and their imported reviews.
Provides option to create new (custom) shelves when importing books.

fixes #3004
fixes #2846
fixes #2666
fixes #2411
This commit is contained in:
Hugh Rundle 2023-11-25 17:34:12 +11:00
parent 7c2de92df3
commit 539a9fa212
No known key found for this signature in database
GPG key ID: A7E35779918253F9
8 changed files with 128 additions and 18 deletions

View file

@ -48,7 +48,16 @@ class Export(View):
fields = (
["title", "author_text"]
+ deduplication_fields
+ ["rating", "review_name", "review_cw", "review_content"]
+ [
"rating",
"review_published",
"review_name",
"review_cw",
"review_content",
"shelf",
"shelf_name",
"date_added",
]
)
writer.writerow(fields)
@ -72,9 +81,23 @@ class Export(View):
.first()
)
if review:
book.review_published = review.published_date
book.review_name = review.name
book.review_cw = review.content_warning
book.review_content = review.raw_content
book.review_content = (
review.raw_content
) # do imported reviews not have raw content?
shelfbook = (
models.ShelfBook.objects.filter(book=book, user=request.user)
.order_by("shelved_date")
.last()
)
if shelfbook:
book.shelf = shelfbook.shelf.identifier
book.shelf_name = shelfbook.shelf.name
book.date_added = shelfbook.shelved_date
writer.writerow([getattr(book, field, "") or "" for field in fields])
return HttpResponse(