Skip to content

Commit

Permalink
Rating Issue Fixed - Only Admin Can Give Rating
Browse files Browse the repository at this point in the history
  • Loading branch information
rshrc committed Jun 8, 2018
1 parent ce8f86a commit 38de7b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Binary file modified accounts/__pycache__/views.cpython-36.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions accounts/templates/accounts/people.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<li>
<div class="content">
<a href="{% url 'view_friend' people.username %}">{{ people.username }}</a>
{% if viewer.is_superuser %}
<p>Name : {{ people.first_name }} {{ people.last_name }} Ratings {% ratings people %}</p>
{% else %}
<p>Name : {{ people.first_name }} {{ people.last_name }} Ratings {% ratings people read_only %}</p>
{% endif %}
</div>
</li>
{% endif %}
Expand Down
4 changes: 4 additions & 0 deletions accounts/templates/accounts/profile_friend.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
<div class="card">
<h1>{{ user.first_name }} {{ user.last_name }}</h1>
<p class="title">Hey, {{ user.username }}</p>
{% if viewer.is_superuser %}
<p>{% ratings user %}</p>
{% else %}
<p>{% ratings user read_only %}</p>
{% endif %}
<a href="#"><i class="fa fa-dribbble"></i></a>
<a href="#"><i class="fa fa-twitter"></i></a>
<a href="#"><i class="fa fa-linkedin"></i></a>
Expand Down
8 changes: 5 additions & 3 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ def ProfileView(request):

def PeopleView(request):
users = User.objects.all() #do not use filter() with User object
args = {'users': users}
args = {'users': users, 'viewer': request.user}
return render(request, 'accounts/people.html', args)


def FriendProfileView(request, username):
try:
user = User.objects.get(username=username).first()
user = User.objects.get(username=username)

except:
raise Http404
Expand All @@ -115,7 +115,9 @@ def FriendProfileView(request, username):
context = locals()
template = 'accounts/profile_friend.html'

return render(request, template, context)
args = {'user': user, 'viewer': request.user}

return render(request, template, args)


#return render(request, 'accounts/profile_friend.html', args)
Expand Down

0 comments on commit 38de7b6

Please sign in to comment.