Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions project/accounts/templates/accounts/user_followers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}

{% block extra_css %}
<link type="text/css" rel="stylesheet/less" href="{% static 'less/utils.less' %}"/>
{% endblock extra_css %}

{% block content %}
<div class="followers-total">
<div>
{% blocktranslate %}
{{ profile.followers.count }} Followers
{% endblocktranslate %}
</div>
</div>
{% for followers in profile.followers.all %}
<div class="col s12 m6">
<div class="user-chip chip white">
<div class="user-chip-contents">
<a href="/profile/{{ followers.user.username }}/">
<img src="{{ followers.profile_image_url }}" alt="{{ followers.user.username }}">
@{{ followers.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 "No followers" %}
</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,
UserFollowers,
ProfileFollowing,
UserProfileView,
UserCivis,
Expand All @@ -34,6 +35,11 @@
path(
"profile/<str:username>/follow", ProfileFollow.as_view(), name="profile-follow"
),
path(
"profile/<str:username>/followers",
UserFollowers.as_view(),
name="user-followers",
),
path(
"profile/<str:username>/unfollow",
ProfileUnfollow.as_view(),
Expand Down
20 changes: 20 additions & 0 deletions project/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ def get(self, request, username=None):
)



class UserFollowers(LoginRequiredMixin, View):
"""A view that shows the followers for authorized users"""

def get(self, request, username=None):
profile = get_object_or_404(Profile, user__username=username)

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


class ProfileFollowing(LoginRequiredMixin, View):
"""
A view that shows list of profiles
Expand All @@ -199,13 +215,16 @@ def get(self, request, username=None):

return TemplateResponse(
request,

"profile_following.html",

{
"profile": profile,
},
)



class UserCivis(LoginRequiredMixin, View):
"""
A view that shows list of civis
Expand All @@ -224,6 +243,7 @@ def get(self, request, username=None):
)



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