Skip to content

Commit

Permalink
Merge pull request #1463 from wippo-devops/add-following-tab
Browse files Browse the repository at this point in the history
Add Following tab to the user profile view
  • Loading branch information
brylie authored Nov 11, 2022
2 parents 207de06 + 7396104 commit b2a60ad
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
34 changes: 34 additions & 0 deletions project/accounts/templates/accounts/profile_following.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% extends "base.html" %}
{% load i18n %}

{% block content %}
<div class="following-total">
<div>
{% blocktranslate %}
{{ profile.following.count }} following
{% endblocktranslate %}
</div>
</div>
{% for following in profile.following.all %}
<div class="col s12 m6">
<div class="user-chip chip white">
<div class="user-chip-contents">
<a href="/profile/{{ following.user.username }}/">
<img src="{{ following.profile_image_url }}" alt="{{ following.user.username }}">
</a>
</div>
</div>
</div>
{% empty %}
<div class="section no-state">
<div class="container">
<div class="section">
<div class="center title-lato grey-text">
{% translate "Not following any users" %}
</div>
</div>
</div>
</div>
{% endfor %}

{% endblock content %}
6 changes: 6 additions & 0 deletions project/accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ProfileUnfollow,
RegisterView,
SettingsView,
ProfileFollowing,
UserProfileView,
expunge_user,
)
Expand Down Expand Up @@ -37,6 +38,11 @@
ProfileUnfollow.as_view(),
name="profile-unfollow",
),
path(
"profile/<str:username>/following",
ProfileFollowing.as_view(),
name="profile-following",
),
path(
"accounts/password_reset/",
PasswordResetView.as_view(),
Expand Down
18 changes: 18 additions & 0 deletions project/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ def get(self, request, username=None):
)


class ProfileFollowing(LoginRequiredMixin, View):
"""
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)

return TemplateResponse(
request,
"profile_following.html",
{
"profile": profile,
},
)


@login_required
def expunge_user(request):
"""
Expand Down

0 comments on commit b2a60ad

Please sign in to comment.