Private
Public Access
1
0

add indication of club size to manager

This commit is contained in:
Sander Roosendaal
2017-04-12 17:39:18 +02:00
parent 29a0f37e03
commit a03c25cc98
4 changed files with 74 additions and 69 deletions

View File

@@ -159,7 +159,7 @@ def create_request(team,user):
if r2 in Rower.objects.filter(team=team):
return (0,'Already a member of that team')
if count_club_members(team.manager)+count_invites(team.manager) < r.clubsize:
if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
codes = [i.code for i in TeamRequest.objects.all()]
code = uuid.uuid4().hex[:10].upper()
# prevent duplicates
@@ -200,7 +200,7 @@ def create_invite(team,manager,user=None,email=''):
except Rower.MultipleObjectsReturned:
return (0,'There is more than one user with that email address')
if count_club_members(team.manager)+count_invites(team.manager) < r.clubsize:
if count_club_members(team.manager)+count_invites(team.manager) <= r.clubsize:
codes = [i.code for i in TeamInvite.objects.all()]
code = uuid.uuid4().hex[:10].upper()
# prevent duplicates

View File

@@ -149,6 +149,7 @@
Teams
</button>
<div class="dropdown-content">
<a class="button gray small" href="/rowers/me/teams/">Manage Teams</a>
{% for t in teams %}
<a class="button gray small" href="/rowers/list-workouts/team/{{ t.id }}/">{{ t.name }}</a>
{% endfor %}

View File

@@ -36,10 +36,76 @@
</p>
</div>
<div class="grid_6 omega">
{% if otherteams %}
<h2>Other Teams</h2>
<table width="70%" class="listtable">
<thead>
<tr>
<th>Name</th>
<th>Manager</th>
</tr>
</thead>
<tbody>
{% for team in otherteams %}
<tr>
<td>
<a href="/rowers/team/{{ team.id }}/">{{ team.name }}</a>
</td>
<td>
{{ team.manager.first_name }} {{ team.manager.last_name }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>&nbsp;</p>
{% endif %}
</div>
</div>
<div class="grid_12 alpha">
<div class="grid_6 alpha">
{% if user.rower.rowerplan == 'coach' %}
<h2>Teams I manage</h2>
<p>Number of members: {{ clubsize }}</p>
<p>Maximum club size: {{ max_clubsize }}</p>
{% if myteams %}
<table width="70%" class="listtable">
<thead>
<tr>
<th>Name</th>
<th>Manager</th>
</tr>
</thead>
<tbody>
{% for team in myteams %}
<tr>
<td>
<a href="/rowers/team/{{ team.id }}/">{{ team.name }}</a>
</td>
<td>
<div class="grid_1">
<a class="button small red" href="/rowers/team/{{ team.id }}/deleteconfirm">Delete</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<div class="grid_2 suffix_4 alpha">
<a class="button green" href="/rowers/team/create">New Team</a>
</div>
{% else %}
<p>&nbsp;</p>
{% endif %}
</div>
<div class="grid_6 omega">
{% if invites or requests or myrequests or myinvites %}
<p>
<h2>Invitations and Requests</h2>
<table width="90%" class="listtable">
<thead>
@@ -126,70 +192,5 @@
</div>
</div>
<div class="grid_12 alpha">
<div class="grid_6 alpha">
{% if user.rower.rowerplan == 'coach' %}
<h2>Teams I manage</h2>
{% if myteams %}
<table width="70%" class="listtable">
<thead>
<tr>
<th>Name</th>
<th>Manager</th>
</tr>
</thead>
<tbody>
{% for team in myteams %}
<tr>
<td>
<a href="/rowers/team/{{ team.id }}/">{{ team.name }}</a>
</td>
<td>
<div class="grid_1">
<a class="button small red" href="/rowers/team/{{ team.id }}/deleteconfirm">Delete</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
<div class="grid_2 suffix_4 alpha">
<a class="button green" href="/rowers/team/create">New Team</a>
</div>
{% else %}
<p>&nbsp;</p>
{% endif %}
</div>
<div class="grid_6 omega">
{% if otherteams %}
<h2>Other Teams</h2>
<table width="70%" class="listtable">
<thead>
<tr>
<th>Name</th>
<th>Manager</th>
</tr>
</thead>
<tbody>
{% for team in otherteams %}
<tr>
<td>
<a href="/rowers/team/{{ team.id }}/">{{ team.name }}</a>
</td>
<td>
{{ team.manager.first_name }} {{ team.manager.last_name }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>&nbsp;</p>
{% endif %}
</div>
</div>
{% endblock %}

View File

@@ -6416,11 +6416,14 @@ def rower_teams_view(request,message='',successmessage=''):
requests = TeamRequest.objects.filter(user=request.user)
myrequests = TeamRequest.objects.filter(team__in=myteams)
myinvites = TeamInvite.objects.filter(team__in=myteams)
clubsize = teams.count_invites(request.user)+teams.count_club_members(request.user)
max_clubsize = r.clubsize
return render(request, 'teams.html',
{
'teams':ts,
'teams':get_my_teams(request.user),
'clubsize':clubsize,
'max_clubsize':max_clubsize,
'myteams':myteams,
'invites':invites,
'otherteams':otherteams,