From cbd76e4f6621daa7658ead127a29d91823d7cfbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Tue, 3 Oct 2023 21:54:47 +0200 Subject: [PATCH] Add a book details page in bookshelf --- ram/bookshelf/models.py | 4 +- ram/portal/templates/base.html | 2 +- ram/portal/templates/bookshelf/book.html | 125 ++++++++++++++++++ .../templates/{ => bookshelf}/books.html | 8 +- .../{ => bookshelf}/bookshelf_menu.html | 0 .../templates/{ => flatpages}/flatpage.html | 0 .../flatpages_menu.html} | 4 +- ram/portal/templatetags/show_menu.py | 8 +- ram/portal/urls.py | 6 +- ram/portal/views.py | 27 +++- 10 files changed, 167 insertions(+), 17 deletions(-) create mode 100644 ram/portal/templates/bookshelf/book.html rename ram/portal/templates/{ => bookshelf}/books.html (93%) rename ram/portal/templates/{ => bookshelf}/bookshelf_menu.html (100%) rename ram/portal/templates/{ => flatpages}/flatpage.html (100%) rename ram/portal/templates/{flatpage_menu.html => flatpages/flatpages_menu.html} (86%) diff --git a/ram/bookshelf/models.py b/ram/bookshelf/models.py index 107dcd7..1f33186 100644 --- a/ram/bookshelf/models.py +++ b/ram/bookshelf/models.py @@ -58,8 +58,8 @@ class Book(models.Model): def publisher_name(self): return self.publisher.name - # def get_absolute_url(self): - # return reverse("books", kwargs={"uuid": self.uuid}) + def get_absolute_url(self): + return reverse("book", kwargs={"uuid": self.uuid}) class BookImage(Image): diff --git a/ram/portal/templates/base.html b/ram/portal/templates/base.html index cf47f37..0dca2e2 100644 --- a/ram/portal/templates/base.html +++ b/ram/portal/templates/base.html @@ -171,7 +171,7 @@
  • Real
  • - {% show_flatpage_menu %} + {% show_flatpages_menu %} {% show_bookshelf_menu %} {% include 'includes/search.html' %} diff --git a/ram/portal/templates/bookshelf/book.html b/ram/portal/templates/bookshelf/book.html new file mode 100644 index 0000000..5731e69 --- /dev/null +++ b/ram/portal/templates/bookshelf/book.html @@ -0,0 +1,125 @@ +{% extends 'base.html' %} + + {% block header %} + {% if book.tags.all %} +

    Tags: + {% for t in book.tags.all %} + {{ t.name }}{# new line is required #} + {% endfor %} +

    + {% endif %} + Updated {{ book.updated_time | date:"M d, Y H:i" }} + {% endblock %} + {% block carousel %} +
    + + {% endblock %} + {% block cards %} + {% endblock %} + {% block extra_content %} +
    +
    +
    + + +
    + {% if request.user.is_staff %}Edit{% endif %} +
    +
    +
    +
    + {% endblock %} diff --git a/ram/portal/templates/books.html b/ram/portal/templates/bookshelf/books.html similarity index 93% rename from ram/portal/templates/books.html rename to ram/portal/templates/bookshelf/books.html index 63998a8..897d6a0 100644 --- a/ram/portal/templates/books.html +++ b/ram/portal/templates/bookshelf/books.html @@ -5,16 +5,16 @@
    {% if d.image.all %} - {# FIXME #} + {% for r in d.image.all %} {% if forloop.first %}Card image cap{% endif %} {% endfor %} - {# FIXME #} + {% endif %}

    {{ d }} - {# #} +

    {% if d.tags.all %}

    Tags: @@ -55,7 +55,7 @@

    - {# FIXME Show all data #} + Show all data {% if request.user.is_staff %}Edit{% endif %}
    diff --git a/ram/portal/templates/bookshelf_menu.html b/ram/portal/templates/bookshelf/bookshelf_menu.html similarity index 100% rename from ram/portal/templates/bookshelf_menu.html rename to ram/portal/templates/bookshelf/bookshelf_menu.html diff --git a/ram/portal/templates/flatpage.html b/ram/portal/templates/flatpages/flatpage.html similarity index 100% rename from ram/portal/templates/flatpage.html rename to ram/portal/templates/flatpages/flatpage.html diff --git a/ram/portal/templates/flatpage_menu.html b/ram/portal/templates/flatpages/flatpages_menu.html similarity index 86% rename from ram/portal/templates/flatpage_menu.html rename to ram/portal/templates/flatpages/flatpages_menu.html index 71267bf..f3fb850 100644 --- a/ram/portal/templates/flatpage_menu.html +++ b/ram/portal/templates/flatpages/flatpages_menu.html @@ -1,10 +1,10 @@ - {% if flatpage_menu %} + {% if flatpages_menu %}