add membership status on team detail and list view

This commit is contained in:
Stephan Telling 2017-04-14 16:13:17 +02:00
parent 6bc0d57a52
commit 033ec1b8b5
4 changed files with 28 additions and 1 deletions

View file

@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load teams_tags %}
{% block title %}
Team: {{ team.name }} | {{ block.super }}
@ -12,6 +13,10 @@ Team: {{ team.name }} | {{ block.super }}
{{ team.description|unsafecommonmark }}
<p>Currently {{ team.members.count }} people are members of this team{% if request.user in team.members.all %} (including you){% endif %}.</p>
{% if request.user in team.members.all %}
<p>Your team status: {% membershipstatus request.user team %}</p>
{% endif %}
{% if request.user in team.members.all %}
<a href="{% url 'team_leave' camp_slug=camp.slug slug=team.slug %}" class="btn btn-danger">Leave Team</a>
{% else %}

View file

@ -1,5 +1,6 @@
{% extends 'base.html' %}
{% load commonmark %}
{% load teams_tags %}
{% block title %}
Teams | {{ block.super }}
@ -21,6 +22,7 @@ Teams | {{ block.super }}
<th>Description</th>
<th>Responsible</th>
<th>Members</th>
<th>Member</th>
<th>Actions</th>
</tr>
</thead>
@ -44,9 +46,21 @@ Teams | {{ block.super }}
<span class="badge">{{ team.members.count }}</span>
</td>
{% if request.user.is_authenticated %}
{% membershipstatus request.user team as membership_status %}
<td class="text-center">
{% if membership_status == 'Membership Pending' %}
<i class='fa fa-clock-o' title='Pending'></i>
{% else %}
{% if membership_status == 'Member' %}
<i class='fa fa-thumbs-o-up' title='Member'></i>
{% else %}
<i class='fa fa-times' title='Not a member'></i>
{% endif %}
{% endif %}
</td>
<td>
{% if request.user in team.members.all %}
<a href="{% url 'team_leave' camp_slug=camp.slug slug=team.slug %}" class="btn btn-danger"><i class="fa fa-minus"></i> Leave</a>
<a href="{% url 'team_leave' camp_slug=camp.slug slug=team.slug %}" class="btn btn-danger"><i class="fa fa-minus"></i> Leave</a>
{% else %}
{% if team.needs_members %}
<a href="{% url 'team_join' camp_slug=camp.slug slug=team.slug %}" class="btn btn-success"><i class="fa fa-plus"></i> Join</button>

View file

View file

@ -0,0 +1,8 @@
from django import template
register = template.Library()
@register.simple_tag
def membershipstatus(user, team):
return team.memberstatus(user)