From 24af288c52115fdff3ae24904a307d34e4e5ce8e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 29 Jan 2021 09:05:53 -0800 Subject: [PATCH] Refactors user pages --- bookwyrm/templates/{ => user}/followers.html | 24 +++++++++---------- bookwyrm/templates/{ => user}/following.html | 24 +++++++++---------- bookwyrm/templates/{ => user}/user.html | 7 +++--- .../user_layout.html} | 10 ++++++++ bookwyrm/views/user.py | 10 ++++---- 5 files changed, 41 insertions(+), 34 deletions(-) rename bookwyrm/templates/{ => user}/followers.html (69%) rename bookwyrm/templates/{ => user}/following.html (70%) rename bookwyrm/templates/{ => user}/user.html (95%) rename bookwyrm/templates/{snippets/user_header.html => user/user_layout.html} (92%) diff --git a/bookwyrm/templates/followers.html b/bookwyrm/templates/user/followers.html similarity index 69% rename from bookwyrm/templates/followers.html rename to bookwyrm/templates/user/followers.html index 00cb13ca..42b8cfb0 100644 --- a/bookwyrm/templates/followers.html +++ b/bookwyrm/templates/user/followers.html @@ -1,18 +1,17 @@ -{% extends 'layout.html' %} +{% extends 'user/user_layout.html' %} {% load bookwyrm_tags %} -{% block content %} -
-

- {% if is_self %}Your - {% else %} - {% include 'snippets/username.html' with user=user possessive=True %} - {% endif %} - followers -

-
-{% include 'snippets/user_header.html' with user=user %} +{% block header %} +

+ {% if is_self %}Your + {% else %} + {% include 'snippets/username.html' with user=user possessive=True %} + {% endif %} + followers +

+{% endblock %} +{% block panel %}

Followers

{% for followers in followers %} @@ -34,5 +33,4 @@
{{ user|username }} has no followers
{% endif %}
- {% endblock %} diff --git a/bookwyrm/templates/following.html b/bookwyrm/templates/user/following.html similarity index 70% rename from bookwyrm/templates/following.html rename to bookwyrm/templates/user/following.html index bdf02c74..9e42b783 100644 --- a/bookwyrm/templates/following.html +++ b/bookwyrm/templates/user/following.html @@ -1,18 +1,17 @@ -{% extends 'layout.html' %} +{% extends 'user/user_layout.html' %} {% load bookwyrm_tags %} -{% block content %} -
-

- Users following - {% if is_self %}you - {% else %} - {% include 'snippets/username.html' with user=user %} - {% endif %} -

-
-{% include 'snippets/user_header.html' with user=user %} +{% block header %} +

+ Users following + {% if is_self %}you + {% else %} + {% include 'snippets/username.html' with user=user %} + {% endif %} +

+{% endblock %} +{% block panel %}

Following

{% for follower in user.following.all %} @@ -34,5 +33,4 @@
{{ user|username }} isn't following any users
{% endif %}
- {% endblock %} diff --git a/bookwyrm/templates/user.html b/bookwyrm/templates/user/user.html similarity index 95% rename from bookwyrm/templates/user.html rename to bookwyrm/templates/user/user.html index 69b762b0..dc3169c2 100644 --- a/bookwyrm/templates/user.html +++ b/bookwyrm/templates/user/user.html @@ -1,6 +1,6 @@ -{% extends 'layout.html' %} -{% block content %} +{% extends 'user/user_layout.html' %} +{% block header %}

User profile

@@ -15,8 +15,9 @@
{% endif %}
+{% endblock %} -{% include 'snippets/user_header.html' with user=user %} +{% block panel %} {% if user.bookwyrm_user %}

Shelves

diff --git a/bookwyrm/templates/snippets/user_header.html b/bookwyrm/templates/user/user_layout.html similarity index 92% rename from bookwyrm/templates/snippets/user_header.html rename to bookwyrm/templates/user/user_layout.html index 8f5e264a..8cf71d9e 100644 --- a/bookwyrm/templates/snippets/user_header.html +++ b/bookwyrm/templates/user/user_layout.html @@ -1,5 +1,12 @@ +{% extends 'layout.html' %} {% load humanize %} {% load bookwyrm_tags %} +
+ {% block header %}{% endblock %} +
+ +{% block content %} +{# user bio #}
@@ -60,3 +67,6 @@ {% endif %}
+{% block panel %}{% endblock %} + +{% endblock %} diff --git a/bookwyrm/views/user.py b/bookwyrm/views/user.py index 4afda01b..4bbd8e29 100644 --- a/bookwyrm/views/user.py +++ b/bookwyrm/views/user.py @@ -90,7 +90,7 @@ class User(View): 'goal': goal, } - return TemplateResponse(request, 'user.html', data) + return TemplateResponse(request, 'user/user.html', data) class Followers(View): ''' list of followers view ''' @@ -115,7 +115,7 @@ class Followers(View): 'is_self': request.user.id == user.id, 'followers': user.followers.all(), } - return TemplateResponse(request, 'followers.html', data) + return TemplateResponse(request, 'user/followers.html', data) class Following(View): ''' list of following view ''' @@ -140,7 +140,7 @@ class Following(View): 'is_self': request.user.id == user.id, 'following': user.following.all(), } - return TemplateResponse(request, 'following.html', data) + return TemplateResponse(request, 'user/following.html', data) @method_decorator(login_required, name='dispatch') @@ -153,7 +153,7 @@ class EditUser(View): 'form': forms.EditUserForm(instance=request.user), 'user': request.user, } - return TemplateResponse(request, 'edit_user.html', data) + return TemplateResponse(request, 'settings/edit_user.html', data) def post(self, request): ''' les get fancy with images ''' @@ -161,7 +161,7 @@ class EditUser(View): request.POST, request.FILES, instance=request.user) if not form.is_valid(): data = {'form': form, 'user': request.user} - return TemplateResponse(request, 'edit_user.html', data) + return TemplateResponse(request, 'settings/edit_user.html', data) user = form.save(commit=False)