From 418e656aea8d5faf1b84afe27337891324f22f0c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 30 Apr 2021 09:17:46 -0700 Subject: [PATCH] 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)