Add a book details page in bookshelf

This commit is contained in:
2023-10-03 21:54:47 +02:00
parent bcfed3534c
commit cbd76e4f66
10 changed files with 167 additions and 17 deletions

View File

@@ -344,10 +344,33 @@ class Types(GetData):
class Books(GetData):
def __init__(self):
self.title = "Books"
self.template = "books.html"
self.template = "bookshelf/books.html"
self.data = Book.objects.all()
class GetBook(View):
def get(self, request, uuid):
try:
book = Book.objects.get(uuid=uuid)
except ObjectDoesNotExist:
raise Http404
book_properties = (
book.property.all()
if request.user.is_authenticated
else book.property.filter(property__private=False)
)
return render(
request,
"bookshelf/book.html",
{
"title": book,
"book_properties": book_properties,
"book": book,
},
)
class GetFlatpage(View):
def get(self, request, flatpage):
try:
@@ -359,6 +382,6 @@ class GetFlatpage(View):
return render(
request,
"flatpage.html",
"flatpages/flatpage.html",
{"title": flatpage.name, "flatpage": flatpage},
)