From d2355fef96e8ea517815a2163239fb70236164d4 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 08:23:02 -0700 Subject: [PATCH 01/11] Consistent display on followers/following pages --- bookwyrm/templates/user/followers.html | 2 +- bookwyrm/templates/user/following.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/user/followers.html b/bookwyrm/templates/user/followers.html index b294db909..2a7ccd1e9 100644 --- a/bookwyrm/templates/user/followers.html +++ b/bookwyrm/templates/user/followers.html @@ -25,7 +25,7 @@ {% endfor %} - {% if not followers.count %} + {% if not followers %}
{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}
{% endif %} diff --git a/bookwyrm/templates/user/following.html b/bookwyrm/templates/user/following.html index 38c01ad27..b41d51264 100644 --- a/bookwyrm/templates/user/following.html +++ b/bookwyrm/templates/user/following.html @@ -20,12 +20,12 @@ ({{ follower.username }}) -
+
{% include 'snippets/follow_button.html' with user=follower %}
{% endfor %} - {% if not following.count %} + {% if not following %}
{% blocktrans with username=user|username %}{{ username }} isn't following any users{% endblocktrans %}
{% endif %} From 862ef835366bb716a47f8716c9713ed301e51b36 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 08:40:47 -0700 Subject: [PATCH 02/11] Move user templates into more subdirectories --- bookwyrm/templates/goal.html | 2 +- .../templates/user/{user_layout.html => layout.html} | 0 .../templates/user/{ => relationships}/followers.html | 2 +- .../templates/user/{ => relationships}/following.html | 2 +- bookwyrm/templates/user/{ => shelf}/books_header.html | 0 .../templates/user/{ => shelf}/create_shelf_form.html | 0 .../templates/user/{ => shelf}/edit_shelf_form.html | 0 bookwyrm/templates/user/{ => shelf}/shelf.html | 10 +++++----- bookwyrm/templates/user/user.html | 8 ++++---- bookwyrm/views/shelf.py | 2 +- bookwyrm/views/user.py | 4 ++-- 11 files changed, 15 insertions(+), 15 deletions(-) rename bookwyrm/templates/user/{user_layout.html => layout.html} (100%) rename bookwyrm/templates/user/{ => relationships}/followers.html (96%) rename bookwyrm/templates/user/{ => relationships}/following.html (96%) rename bookwyrm/templates/user/{ => shelf}/books_header.html (100%) rename bookwyrm/templates/user/{ => shelf}/create_shelf_form.html (100%) rename bookwyrm/templates/user/{ => shelf}/edit_shelf_form.html (100%) rename bookwyrm/templates/user/{ => shelf}/shelf.html (94%) diff --git a/bookwyrm/templates/goal.html b/bookwyrm/templates/goal.html index 32b5062dc..22aba08e4 100644 --- a/bookwyrm/templates/goal.html +++ b/bookwyrm/templates/goal.html @@ -1,4 +1,4 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load i18n %} {% block header %} diff --git a/bookwyrm/templates/user/user_layout.html b/bookwyrm/templates/user/layout.html similarity index 100% rename from bookwyrm/templates/user/user_layout.html rename to bookwyrm/templates/user/layout.html diff --git a/bookwyrm/templates/user/followers.html b/bookwyrm/templates/user/relationships/followers.html similarity index 96% rename from bookwyrm/templates/user/followers.html rename to bookwyrm/templates/user/relationships/followers.html index 2a7ccd1e9..c69416dce 100644 --- a/bookwyrm/templates/user/followers.html +++ b/bookwyrm/templates/user/relationships/followers.html @@ -1,4 +1,4 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load i18n %} {% load bookwyrm_tags %} diff --git a/bookwyrm/templates/user/following.html b/bookwyrm/templates/user/relationships/following.html similarity index 96% rename from bookwyrm/templates/user/following.html rename to bookwyrm/templates/user/relationships/following.html index b41d51264..a1feeb76a 100644 --- a/bookwyrm/templates/user/following.html +++ b/bookwyrm/templates/user/relationships/following.html @@ -1,4 +1,4 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load i18n %} {% load bookwyrm_tags %} diff --git a/bookwyrm/templates/user/books_header.html b/bookwyrm/templates/user/shelf/books_header.html similarity index 100% rename from bookwyrm/templates/user/books_header.html rename to bookwyrm/templates/user/shelf/books_header.html diff --git a/bookwyrm/templates/user/create_shelf_form.html b/bookwyrm/templates/user/shelf/create_shelf_form.html similarity index 100% rename from bookwyrm/templates/user/create_shelf_form.html rename to bookwyrm/templates/user/shelf/create_shelf_form.html diff --git a/bookwyrm/templates/user/edit_shelf_form.html b/bookwyrm/templates/user/shelf/edit_shelf_form.html similarity index 100% rename from bookwyrm/templates/user/edit_shelf_form.html rename to bookwyrm/templates/user/shelf/edit_shelf_form.html diff --git a/bookwyrm/templates/user/shelf.html b/bookwyrm/templates/user/shelf/shelf.html similarity index 94% rename from bookwyrm/templates/user/shelf.html rename to bookwyrm/templates/user/shelf/shelf.html index 336162588..93f0c15f2 100644 --- a/bookwyrm/templates/user/shelf.html +++ b/bookwyrm/templates/user/shelf/shelf.html @@ -1,16 +1,16 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load bookwyrm_tags %} {% load humanize %} {% load i18n %} {% block title %} -{% include 'user/books_header.html' %} +{% include 'user/shelf/books_header.html' %} {% endblock %} {% block header %}

- {% include 'user/books_header.html' %} + {% include 'user/shelf/books_header.html' %}

{% endblock %} @@ -41,7 +41,7 @@
- {% include 'user/create_shelf_form.html' with controls_text='create-shelf-form' %} + {% include 'user/shelf/create_shelf_form.html' with controls_text='create-shelf-form' %}
@@ -62,7 +62,7 @@
- {% include 'user/edit_shelf_form.html' with controls_text="edit-shelf-form" %} + {% include 'user/shelf/edit_shelf_form.html' with controls_text="edit-shelf-form" %}
diff --git a/bookwyrm/templates/user/user.html b/bookwyrm/templates/user/user.html index a97d26ab8..fead8fcf6 100644 --- a/bookwyrm/templates/user/user.html +++ b/bookwyrm/templates/user/user.html @@ -1,4 +1,4 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load i18n %} {% load bookwyrm_tags %} @@ -11,7 +11,7 @@
{% if is_self %}
- + {% trans "Edit profile" %} @@ -25,7 +25,7 @@ {% if user.bookwyrm_user %}

- {% include 'user/books_header.html' %} + {% include 'user/shelf/books_header.html' %}

{% for shelf in shelves %} @@ -56,7 +56,7 @@ {% elif user == request.user %} {% endif %} diff --git a/bookwyrm/views/shelf.py b/bookwyrm/views/shelf.py index 9bcf0a4ac..ca05ec1ee 100644 --- a/bookwyrm/views/shelf.py +++ b/bookwyrm/views/shelf.py @@ -68,7 +68,7 @@ class Shelf(View): "books": paginated.get_page(request.GET.get("page")), } - return TemplateResponse(request, "user/shelf.html", data) + return TemplateResponse(request, "user/shelf/shelf.html", data) @method_decorator(login_required, name="dispatch") # pylint: disable=unused-argument diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py index d394c1d73..af31fd47f 100644 --- a/bookwyrm/views/user.py +++ b/bookwyrm/views/user.py @@ -112,7 +112,7 @@ class Followers(View): "is_self": request.user.id == user.id, "followers": paginated.page(request.GET.get("page", 1)), } - return TemplateResponse(request, "user/followers.html", data) + return TemplateResponse(request, "user/relationships/followers.html", data) class Following(View): @@ -138,7 +138,7 @@ class Following(View): "is_self": request.user.id == user.id, "following": paginated.page(request.GET.get("page", 1)), } - return TemplateResponse(request, "user/following.html", data) + return TemplateResponse(request, "user/relationships/following.html", data) @method_decorator(login_required, name="dispatch") From e4cecf2874103890be40f376cb399e2e21e7036c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 09:02:14 -0700 Subject: [PATCH 03/11] Coherent logic on which tabs show in the user page --- bookwyrm/templates/user/layout.html | 4 ++-- bookwyrm/templates/user/lists.html | 2 +- bookwyrm/templates/user/shelf/shelf.html | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/user/layout.html b/bookwyrm/templates/user/layout.html index 0c3e94e3c..0f04f6288 100644 --- a/bookwyrm/templates/user/layout.html +++ b/bookwyrm/templates/user/layout.html @@ -41,8 +41,8 @@
{% endif %}
+{% block tabs %} {% with user|username as username %} -{% if 'user/'|add:username|add:'/books' not in request.path and 'user/'|add:username|add:'/shelf' not in request.path %} -{% endif %} {% endwith %} +{% endblock %} {% block panel %}{% endblock %} diff --git a/bookwyrm/templates/user/lists.html b/bookwyrm/templates/user/lists.html index b2fd9eefd..aa8ad7fb6 100644 --- a/bookwyrm/templates/user/lists.html +++ b/bookwyrm/templates/user/lists.html @@ -1,4 +1,4 @@ -{% extends 'user/user_layout.html' %} +{% extends 'user/layout.html' %} {% load i18n %} {% block header %} diff --git a/bookwyrm/templates/user/shelf/shelf.html b/bookwyrm/templates/user/shelf/shelf.html index 93f0c15f2..639ab502f 100644 --- a/bookwyrm/templates/user/shelf/shelf.html +++ b/bookwyrm/templates/user/shelf/shelf.html @@ -15,7 +15,7 @@ {% endblock %} -{% block panel %} +{% block tabs %}
@@ -39,7 +39,9 @@
{% endif %}
+{% endblock %} +{% block panel %}
{% include 'user/shelf/create_shelf_form.html' with controls_text='create-shelf-form' %}
From 418e656aea8d5faf1b84afe27337891324f22f0c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 09:17:46 -0700 Subject: [PATCH 04/11] Uses layout for followers/following page --- bookwyrm/templates/user/layout.html | 6 +++- .../user/relationships/followers.html | 30 ++++--------------- .../user/relationships/following.html | 30 ++++--------------- .../templates/user/relationships/layout.html | 29 ++++++++++++++++++ bookwyrm/views/user.py | 6 ++-- 5 files changed, 47 insertions(+), 54 deletions(-) create mode 100644 bookwyrm/templates/user/relationships/layout.html diff --git a/bookwyrm/templates/user/layout.html b/bookwyrm/templates/user/layout.html index 0f04f6288..dcdf7ccfc 100644 --- a/bookwyrm/templates/user/layout.html +++ b/bookwyrm/templates/user/layout.html @@ -7,7 +7,11 @@ {% block content %}
- {% block header %}{% endblock %} + {% block header %} +

+ {% trans "User Profile" %} +

+ {% endblock %}
{# user bio #} diff --git a/bookwyrm/templates/user/relationships/followers.html b/bookwyrm/templates/user/relationships/followers.html index c69416dce..223f38c7b 100644 --- a/bookwyrm/templates/user/relationships/followers.html +++ b/bookwyrm/templates/user/relationships/followers.html @@ -1,34 +1,14 @@ -{% extends 'user/layout.html' %} +{% extends 'user/relationships/layout.html' %} {% load i18n %} -{% load bookwyrm_tags %} {% block header %}

- {% trans "User Profile" %} + {% trans "Followers" %}

{% endblock %} -{% block panel %} -
-

{% trans "Followers" %}

- {% for follower in followers %} -
- -
- {% include 'snippets/follow_button.html' with user=follower %} -
-
- {% endfor %} - {% if not followers %} -
{% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}
- {% endif %} +{% block nullstate %} +
+ {% blocktrans with username=user.display_name %}{{ username }} has no followers{% endblocktrans %}
- -{% include 'snippets/pagination.html' with page=followers path=request.path %} {% endblock %} diff --git a/bookwyrm/templates/user/relationships/following.html b/bookwyrm/templates/user/relationships/following.html index a1feeb76a..5689bc613 100644 --- a/bookwyrm/templates/user/relationships/following.html +++ b/bookwyrm/templates/user/relationships/following.html @@ -1,34 +1,14 @@ -{% extends 'user/layout.html' %} +{% extends 'user/relationships/layout.html' %} {% load i18n %} -{% load bookwyrm_tags %} {% block header %}

- {% trans "User Profile" %} + {% trans "Following" %}

{% endblock %} -{% block panel %} -
-

{% trans "Following" %}

- {% for follower in user.following.all %} -
- -
- {% include 'snippets/follow_button.html' with user=follower %} -
-
- {% endfor %} - {% if not following %} -
{% blocktrans with username=user|username %}{{ username }} isn't following any users{% endblocktrans %}
- {% endif %} +{% block nullstate %} +
+ {% blocktrans with username=user.display_name %}{{ username }} isn't following any users{% endblocktrans %}
- -{% include 'snippets/pagination.html' with page=following path=request.path %} {% endblock %} diff --git a/bookwyrm/templates/user/relationships/layout.html b/bookwyrm/templates/user/relationships/layout.html new file mode 100644 index 000000000..ab38e6620 --- /dev/null +++ b/bookwyrm/templates/user/relationships/layout.html @@ -0,0 +1,29 @@ +{% extends 'user/layout.html' %} +{% load i18n %} +{% load bookwyrm_tags %} + +{% block panel %} +
+ {% for follow in follow_list %} +
+ +
+ {% include 'snippets/follow_button.html' with user=follow %} +
+
+ {% endfor %} + + {% if not follow_list %} + {% block nullstate %} + {% endblock %} + {% endif %} +
+ +{% include 'snippets/pagination.html' with page=follow_list path=request.path %} +{% endblock %} diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py index af31fd47f..5584ce991 100644 --- a/bookwyrm/views/user.py +++ b/bookwyrm/views/user.py @@ -110,7 +110,7 @@ class Followers(View): data = { "user": user, "is_self": request.user.id == user.id, - "followers": paginated.page(request.GET.get("page", 1)), + "follow_list": paginated.page(request.GET.get("page", 1)), } return TemplateResponse(request, "user/relationships/followers.html", data) @@ -132,11 +132,11 @@ class Following(View): if is_api_request(request): return ActivitypubResponse(user.to_following_activity(**request.GET)) - paginated = Paginator(user.followers.all(), PAGE_LENGTH) + paginated = Paginator(user.following.all(), PAGE_LENGTH) data = { "user": user, "is_self": request.user.id == user.id, - "following": paginated.page(request.GET.get("page", 1)), + "follow_list": paginated.page(request.GET.get("page", 1)), } return TemplateResponse(request, "user/relationships/following.html", data) From b65d0d05c9f49c375f32f8252d33a091aac3f0aa Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 09:23:59 -0700 Subject: [PATCH 05/11] Tabs for relationship views --- bookwyrm/templates/user/layout.html | 1 + .../templates/user/relationships/layout.html | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/bookwyrm/templates/user/layout.html b/bookwyrm/templates/user/layout.html index dcdf7ccfc..661d80781 100644 --- a/bookwyrm/templates/user/layout.html +++ b/bookwyrm/templates/user/layout.html @@ -45,6 +45,7 @@
{% endif %}
+ {% block tabs %} {% with user|username as username %}