show members and applicants on team detail page

This commit is contained in:
James Tauber 2012-08-02 13:03:16 -04:00
parent e96e416bdc
commit 7db401e9a2
2 changed files with 35 additions and 0 deletions

View file

@ -31,6 +31,18 @@ class Team(models.Model):
return self.memberships.get(user=user).state
except Membership.DoesNotExist:
return None
def applicants(self):
return self.memberships.filter(state="applied")
def invitees(self):
return self.memberships.filter(state="invited")
def members(self):
return self.memberships.filter(state="member")
def managers(self):
return self.memberships.filter(state="manager")
MEMBERSHIP_STATE_CHOICES = [

View file

@ -28,4 +28,27 @@
</form>
{% endif %}
{% if user.is_staff or state == "manager" %}
{% if team.members %}
<h2>Team Members</h2>
<table class="table table-striped">
{% for membership in team.members %}
<tr>
<td>{{ membership.user.email }}</td>
<td>{{ membership.state }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% if team.applicants and team.access == "application" %}
<h2>Applicants</h2>
<table class="table table-striped">
{% for membership in team.applicants %}
<tr>
<td>{{ membership.user.email }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endif %}
{% endblock %}