From 3a1bc1150b3709f733bd7faf8efb2f437d080fac Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Sat, 5 Nov 2022 22:16:56 +0100 Subject: [PATCH 1/6] Add Following tab to the user profile view --- .../templates/accounts/user_civis.html | 41 +++++++++++++++++++ project/accounts/urls.py | 6 +++ project/accounts/views.py | 15 +++++++ 3 files changed, 62 insertions(+) create mode 100644 project/accounts/templates/accounts/user_civis.html diff --git a/project/accounts/templates/accounts/user_civis.html b/project/accounts/templates/accounts/user_civis.html new file mode 100644 index 00000000..d53fdd38 --- /dev/null +++ b/project/accounts/templates/accounts/user_civis.html @@ -0,0 +1,41 @@ +{% extends "base.html" %} + +{% block extra-css%}{% endblock extra-css %} + +{% block content %} +
+
+ {{ profile.following.count }} Following +
+
+ {% for following in profile.following.all %} +
+
+ +
+
+ {% empty %} +
+
+
+
+ Not following any users +
+
+
+
+ {% endfor %} + +{% endblock content %} + +{% block extra-js %}{% endblock extra-js %} diff --git a/project/accounts/urls.py b/project/accounts/urls.py index f9c4ceb9..85ad0020 100644 --- a/project/accounts/urls.py +++ b/project/accounts/urls.py @@ -8,6 +8,7 @@ ProfileUnfollow, RegisterView, SettingsView, + UserFollowing, UserProfileView, expunge_user, ) @@ -37,6 +38,11 @@ ProfileUnfollow.as_view(), name="profile-unfollow", ), + path( + "profile//following", + UserFollowing.as_view(), + name="profile-following", + ), path( "accounts/password_reset/", PasswordResetView.as_view(), diff --git a/project/accounts/views.py b/project/accounts/views.py index e0d68b60..8dbd49e2 100644 --- a/project/accounts/views.py +++ b/project/accounts/views.py @@ -188,6 +188,21 @@ def get(self, request, username=None): ) +class UserFollowing(LoginRequiredMixin, View): + """A view that shows list of users following user with given username""" + + def get(self, request, username=None): + profile = get_object_or_404(Profile, user__username=username) + + return TemplateResponse( + request, + "user_civis.html", + { + "profile": profile, + }, + ) + + @login_required def expunge_user(request): """ From afc757747a7f5d0e81b4ee460969d931b2b9c041 Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Mon, 7 Nov 2022 14:43:40 +0100 Subject: [PATCH 2/6] Implement suggested changes in #1463 --- .../accounts/{user_civis.html => profile_followers.html} | 0 project/accounts/views.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename project/accounts/templates/accounts/{user_civis.html => profile_followers.html} (100%) diff --git a/project/accounts/templates/accounts/user_civis.html b/project/accounts/templates/accounts/profile_followers.html similarity index 100% rename from project/accounts/templates/accounts/user_civis.html rename to project/accounts/templates/accounts/profile_followers.html diff --git a/project/accounts/views.py b/project/accounts/views.py index 8dbd49e2..1811bd17 100644 --- a/project/accounts/views.py +++ b/project/accounts/views.py @@ -196,7 +196,7 @@ def get(self, request, username=None): return TemplateResponse( request, - "user_civis.html", + "profile_followers.html", { "profile": profile, }, From 2e6d9453cfa7f35a079b4f2a16fc8ec44c77953f Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Mon, 7 Nov 2022 14:49:45 +0100 Subject: [PATCH 3/6] Implement suggested changes in #1463 --- .../templates/accounts/profile_followers.html | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/project/accounts/templates/accounts/profile_followers.html b/project/accounts/templates/accounts/profile_followers.html index d53fdd38..496175b7 100644 --- a/project/accounts/templates/accounts/profile_followers.html +++ b/project/accounts/templates/accounts/profile_followers.html @@ -1,11 +1,12 @@ {% extends "base.html" %} - -{% block extra-css%}{% endblock extra-css %} +{% load i18n %} {% block content %}
- {{ profile.following.count }} Following + {% blocktranslate %} + {{ profile.following.count }} following + {% endblocktranslate %}
{% for following in profile.following.all %} @@ -14,12 +15,6 @@ @@ -29,7 +24,7 @@
- Not following any users + {% translate "Not following any users" %}
@@ -37,5 +32,3 @@ {% endfor %} {% endblock content %} - -{% block extra-js %}{% endblock extra-js %} From 0c35b874dbd6eda03b7e38ee9d86a4a6455564b5 Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Tue, 8 Nov 2022 20:15:01 +0100 Subject: [PATCH 4/6] Rename view to Profile Following and ensure consistency between view and template --- .../{profile_followers.html => profile_following.html} | 0 project/accounts/urls.py | 4 ++-- project/accounts/views.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename project/accounts/templates/accounts/{profile_followers.html => profile_following.html} (100%) diff --git a/project/accounts/templates/accounts/profile_followers.html b/project/accounts/templates/accounts/profile_following.html similarity index 100% rename from project/accounts/templates/accounts/profile_followers.html rename to project/accounts/templates/accounts/profile_following.html diff --git a/project/accounts/urls.py b/project/accounts/urls.py index 85ad0020..a008713b 100644 --- a/project/accounts/urls.py +++ b/project/accounts/urls.py @@ -8,7 +8,7 @@ ProfileUnfollow, RegisterView, SettingsView, - UserFollowing, + ProfileFollowing, UserProfileView, expunge_user, ) @@ -40,7 +40,7 @@ ), path( "profile//following", - UserFollowing.as_view(), + ProfileFollowing.as_view(), name="profile-following", ), path( diff --git a/project/accounts/views.py b/project/accounts/views.py index 1811bd17..c9a081b8 100644 --- a/project/accounts/views.py +++ b/project/accounts/views.py @@ -188,7 +188,7 @@ def get(self, request, username=None): ) -class UserFollowing(LoginRequiredMixin, View): +class ProfileFollowing(LoginRequiredMixin, View): """A view that shows list of users following user with given username""" def get(self, request, username=None): @@ -196,7 +196,7 @@ def get(self, request, username=None): return TemplateResponse( request, - "profile_followers.html", + "profile_following.html", { "profile": profile, }, From 304063bd2be200ce03d2e2e38569a28a026272fc Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Wed, 9 Nov 2022 16:24:51 +0100 Subject: [PATCH 5/6] Changed docstring to fit the view description --- project/accounts/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/accounts/views.py b/project/accounts/views.py index c9a081b8..48e84a7f 100644 --- a/project/accounts/views.py +++ b/project/accounts/views.py @@ -189,7 +189,7 @@ def get(self, request, username=None): class ProfileFollowing(LoginRequiredMixin, View): - """A view that shows list of users following user with given username""" + """A view that shows list of profiles that profile with given username is following""" def get(self, request, username=None): profile = get_object_or_404(Profile, user__username=username) From 73961041a16b34956b18499458f699daa0a5a118 Mon Sep 17 00:00:00 2001 From: Mikulas Zupcan Date: Wed, 9 Nov 2022 16:30:43 +0100 Subject: [PATCH 6/6] Fix docustring being too long --- project/accounts/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/project/accounts/views.py b/project/accounts/views.py index 48e84a7f..a49d77b6 100644 --- a/project/accounts/views.py +++ b/project/accounts/views.py @@ -189,7 +189,10 @@ def get(self, request, username=None): class ProfileFollowing(LoginRequiredMixin, View): - """A view that shows list of profiles that profile with given username is following""" + """ + A view that shows list of profiles + that profile with given username is following + """ def get(self, request, username=None): profile = get_object_or_404(Profile, user__username=username)