Skip to content

Commit

Permalink
Added feature to see the followers (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitanand001 authored and Martti Sasi committed Aug 31, 2017
1 parent 673d2b3 commit 8b7c742
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions bugheist/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
url(r'^like_issue/(?P<issue_pk>\d+)/$', website.views.like_issue,name="like_issue"),
url(r'^issue/edit/$', website.views.IssueEdit),
url(r'^issue/update/$', website.views.UpdateIssue),
url(r'^like_issue/(?P<username>\w+)/$', website.views.follower_list,name="follower_list"),
url(r'^issue/(?P<slug>\w+)/$', IssueView.as_view(), name="issue_view"),
url(r'^follow_user/(?P<user>[^/]+)/', website.views.follow_user,name="follow_user"),
url(r'^all_activity/$', AllIssuesView.as_view(), name="all_activity"),
Expand Down
23 changes: 23 additions & 0 deletions website/templates/follower_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load gravatar %}
{% load staticfiles %}
{% load humanize %}

{% block content %}
<div class="col-md-8 col-md-offset-2">
<h2> Followers: </h2>
<div class="list-group">
{% for user in followers %}
<div class="list-group-item">
{% if user.socialaccount_set.all.0.get_avatar_url %}
<img src="{{user.socialaccount_set.all.0.get_avatar_url}}" height="50px">
{% else %}
<img src="{% gravatar_url user.email 50 %}">
{% endif %}
<a href="/profile/{{user.username}}">{{user.username}}</a>
</div>
{% endfor %}
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion website/templates/followers.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
</div>

<h4>Following: <strong>{{ follows }}</strong></h4>
<h4>Followed by: <strong>{{ followed_by }}</strong></h4>
<h4>Followed by: <strong><a href="{% url 'follower_list' username=user %}">{{ followed_by }}</a></strong></h4>

10 changes: 10 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,3 +901,13 @@ def like_issue(request,issue_pk):
context['object'] = issue
context['likes'] = total_votes
return render(request,'likers.html',context)
def follower_list(request,username):
user = User.objects.get(username=username)
context={}
lis = []
prof_list = user.userprofile.follower.all()
for userprofile in prof_list:
user = User.objects.get(username=str(userprofile.user))
lis.append(user)
context['followers'] = lis
return render(request,'follower_list.html',context)

0 comments on commit 8b7c742

Please sign in to comment.