From 6c629be6678ed34bff271d89e7e59c756b0b6214 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 21 Feb 2020 16:03:05 -0800 Subject: [PATCH] Adds shelf page Works on #25 --- fedireads/templates/feed.html | 2 +- fedireads/templates/shelf.html | 10 ++++ fedireads/templates/snippets/shelf.html | 61 ++++++++++++++++++++++ fedireads/templates/snippets/username.html | 4 +- fedireads/templates/user.html | 57 +------------------- fedireads/templatetags/fr_display.py | 7 +++ fedireads/urls.py | 2 +- fedireads/views.py | 27 ++++++++-- 8 files changed, 105 insertions(+), 65 deletions(-) create mode 100644 fedireads/templates/shelf.html create mode 100644 fedireads/templates/snippets/shelf.html diff --git a/fedireads/templates/feed.html b/fedireads/templates/feed.html index 01f7acda4..475b966e7 100644 --- a/fedireads/templates/feed.html +++ b/fedireads/templates/feed.html @@ -14,7 +14,7 @@ {% endfor %} {% if shelf.size > shelf.books.count %} - See all {{ shelf.size }} + See all {{ shelf.size }} {% endif %} {% endfor %} diff --git a/fedireads/templates/shelf.html b/fedireads/templates/shelf.html new file mode 100644 index 000000000..afb6d52c1 --- /dev/null +++ b/fedireads/templates/shelf.html @@ -0,0 +1,10 @@ +{% extends 'layout.html' %} +{% block content %} + +
+
+

{% include 'snippets/username.html' %} > {{ shelf.name }}

+ {% include 'snippets/shelf.html' with shelf=shelf ratings=ratings %} +
+
+{% endblock %} diff --git a/fedireads/templates/snippets/shelf.html b/fedireads/templates/snippets/shelf.html new file mode 100644 index 000000000..651a4808e --- /dev/null +++ b/fedireads/templates/snippets/shelf.html @@ -0,0 +1,61 @@ +{% load humanize %} +{% load fr_display %} +{% if shelf.books %} + + + + + + + + + {% if ratings %} + + {% endif %} + +{% for book in shelf.books.all %} + + + + + + + + {% if ratings %} + + {% endif %} + +{% endfor %} +
+ Cover + + Title + + Author + + Published + + Shelved + + External links + + Rating +
+ {% include 'snippets/book_cover.html' with book=book %} + + {{ book.data.title }} + + {{ book.authors.first.data.name }} + + {{ book.data.first_publish_date }} + + {{ book.added_date | naturalday }} + + OpenLibrary + + {{ ratings | dict_key:book.id | stars}} +
+{% else %} +

This shelf is empty.

+{% endif %} + diff --git a/fedireads/templates/snippets/username.html b/fedireads/templates/snippets/username.html index ff270fa32..16505c86a 100644 --- a/fedireads/templates/snippets/username.html +++ b/fedireads/templates/snippets/username.html @@ -1,2 +1,2 @@ -{% if user.name %}{{ user.name }}{% elif user.localname %}{{ user.localname }}{% else %}{{ user.username }}{% endif %} - +{% load fr_display %} +{% if user.name %}{{ user.name }}{% else %}{{ user | username }}{% endif %} diff --git a/fedireads/templates/user.html b/fedireads/templates/user.html index ff3f06ba2..9f095e462 100644 --- a/fedireads/templates/user.html +++ b/fedireads/templates/user.html @@ -1,6 +1,4 @@ {% extends 'layout.html' %} -{% load humanize %} -{% load fr_display %} {% block content %}