Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris Komaroff
Courses Plus Student 14,198 PointsAny chance of supplying the "snippet" code for template community_detail.html?
This is the template code that requires the user viewing community_detail.html to have the ban_member permission to ban a member from the community. I will try to copy from video screenshots. I don't see the source code in S2V5 projects files.
4 Answers
Chris Komaroff
Courses Plus Student 14,198 PointsHere is missing template code I added, copied from video, no guarantees, but it appears to work for me:
communities/community_detail.html
<div class="card card-with-shadow">
<div class="content">
<h5 class="title">Members</h5>
<ul class="list-unstyled">
{% for membership in community.good_members %}
<li class="row">
<a href="{% url 'posts:for_user' username=membership.user.username %}" class="col-md-9">{{ membership.user.display_name }}</a>
<div class="col-md-3 text-right">
{% if user.id in community.admins or user.id in community.moderators %}
{% if membership.user.id in community.moderators %}
<a href="{% url 'communities:change_status' slug=community.slug user_id=membership.user.id status=1 %}"><i class="glyphicon glyphicon-thumbs-down text-warning"></i></a>
{% endif %}
{% if membership.user.id not in community.moderators and membership.user.id not in community.admins %}
<a href="{% url 'communities:change_status' slug=community.slug user_id=membership.user.id status=2 %}"><i class="glyphicon glyphicon-thumbs-up text-warning"></i></a>
{% endif %}
{% if perms.communities.ban_member %}
<a href="{% url 'communities:change_status' slug=community.slug user_id=membership.user.id status=0 %}"><i class="glyphicon glyphicon-ban-circle text-danger"></i></a>
{% endif %}
{% endif %}
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
Chris Freeman
Treehouse Moderator 68,441 PointsMoved to answer.
Greg Kaleka
39,021 PointsChris,
Thanks for this! I found one small error - the second class for the top level div should be card-with-shadow
instead of card-with-shadows
.
I took the liberty of editing your answer just in case others use it.
Cheers
-Greg
Chris Freeman
Treehouse Moderator 68,441 PointsMarking Best Answer.
Ian Salmon
Courses Plus Student 10,687 PointsThanks for this!
Cristian Romero
11,911 PointsThank you!!!
Milly Clervil
37 PointsHow to use multiple user type in django with some example please?
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsTagging Kenneth Love