Export bookshelves and review date
This commit is contained in:
parent
b04ebe397b
commit
854eb36618
2 changed files with 39 additions and 6 deletions
|
@ -17,6 +17,7 @@ from bookwyrm import models
|
|||
from bookwyrm.models.bookwyrm_export_job import BookwyrmExportJob
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
|
||||
|
||||
# pylint: disable=no-self-use,too-many-locals
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
class Export(View):
|
||||
|
@ -54,8 +55,19 @@ class Export(View):
|
|||
fields = (
|
||||
["title", "author_text"]
|
||||
+ deduplication_fields
|
||||
+ ["start_date", "finish_date", "stopped_date"]
|
||||
+ ["rating", "review_name", "review_cw", "review_content"]
|
||||
+ [
|
||||
"start_date",
|
||||
"finish_date",
|
||||
"stopped_date",
|
||||
"rating",
|
||||
"review_name",
|
||||
"review_cw",
|
||||
"review_content",
|
||||
"review_published",
|
||||
"shelf",
|
||||
"shelf_name",
|
||||
"shelf_date",
|
||||
]
|
||||
)
|
||||
writer.writerow(fields)
|
||||
|
||||
|
@ -97,9 +109,27 @@ class Export(View):
|
|||
.first()
|
||||
)
|
||||
if review:
|
||||
book.review_published = (
|
||||
review.published_date.date() if review.published_date else None
|
||||
)
|
||||
book.review_name = review.name
|
||||
book.review_cw = review.content_warning
|
||||
book.review_content = review.raw_content
|
||||
book.review_content = (
|
||||
review.raw_content if review.raw_content else review.content
|
||||
) # GoodReads imported reviews do not have raw_content, but content.
|
||||
|
||||
shelfbook = (
|
||||
models.ShelfBook.objects.filter(user=request.user, book=book)
|
||||
.order_by("-shelved_date", "-created_date", "-updated_date")
|
||||
.last()
|
||||
)
|
||||
if shelfbook:
|
||||
book.shelf = shelfbook.shelf.identifier
|
||||
book.shelf_name = shelfbook.shelf.name
|
||||
book.shelf_date = (
|
||||
shelfbook.shelved_date.date() if shelfbook.shelved_date else None
|
||||
)
|
||||
|
||||
writer.writerow([getattr(book, field, "") or "" for field in fields])
|
||||
|
||||
return HttpResponse(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue