From a03c25cc9884168c9088c1753f76688b5b4093d6 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 12 Apr 2017 17:39:18 +0200 Subject: [PATCH 1/6] add indication of club size to manager --- rowers/teams.py | 4 +- rowers/templates/base.html | 1 + rowers/templates/teams.html | 133 ++++++++++++++++++------------------ rowers/views.py | 5 +- 4 files changed, 74 insertions(+), 69 deletions(-) diff --git a/rowers/teams.py b/rowers/teams.py index dcf7371b..6ab792d3 100644 --- a/rowers/teams.py +++ b/rowers/teams.py @@ -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 diff --git a/rowers/templates/base.html b/rowers/templates/base.html index c5677acc..13c4d985 100644 --- a/rowers/templates/base.html +++ b/rowers/templates/base.html @@ -149,6 +149,7 @@ Teams +
+ {% if otherteams %} +

Other Teams

+ + + + + + + + + {% for team in otherteams %} + + + + + {% endfor %} + +
NameManager
+ {{ team.name }} + + {{ team.manager.first_name }} {{ team.manager.last_name }} +
+ + {% else %} +

 

+ {% endif %} +
+ + +
+
+ {% if user.rower.rowerplan == 'coach' %} +

Teams I manage

+

Number of members: {{ clubsize }}

+

Maximum club size: {{ max_clubsize }}

+ {% if myteams %} + + + + + + + + + {% for team in myteams %} + + + + + {% endfor %} + +
NameManager
+ {{ team.name }} + +
+ Delete +
+
+ {% endif %} +
+ New Team +
+ {% else %} +

 

+ {% endif %}
{% if invites or requests or myrequests or myinvites %} -

Invitations and Requests

@@ -126,70 +192,5 @@ -
-
- {% if user.rower.rowerplan == 'coach' %} -

Teams I manage

- {% if myteams %} -
- - - - - - - - {% for team in myteams %} - - - - - {% endfor %} - -
NameManager
- {{ team.name }} - -
- Delete -
-
- {% endif %} -
- New Team -
- {% else %} -

 

- {% endif %} -
-
- {% if otherteams %} -

Other Teams

- - - - - - - - - {% for team in otherteams %} - - - - - {% endfor %} - -
NameManager
- {{ team.name }} - - {{ team.manager.first_name }} {{ team.manager.last_name }} -
- - {% else %} -

 

- {% endif %} -
-
- {% endblock %} diff --git a/rowers/views.py b/rowers/views.py index 387bcb4e..837296b1 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -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, From 35f1fb5b593e83466fe03ecee883831075ca0076 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Thu, 13 Apr 2017 11:39:51 +0200 Subject: [PATCH 2/6] team manager can upload on behalf of team member --- rowers/forms.py | 18 +++ rowers/templates/base.html | 10 +- rowers/templates/basefront.html | 9 +- rowers/templates/document_form.html | 7 +- rowers/templates/list_workouts.html | 4 +- rowers/templates/team_document_form.html | 55 +++++++ rowers/templates/teambuttons.html | 16 +- rowers/templatetags/rowerfilters.py | 32 ++++ rowers/urls.py | 6 +- rowers/views.py | 183 ++++++++++++++++++++++- 10 files changed, 328 insertions(+), 12 deletions(-) create mode 100644 rowers/templates/team_document_form.html diff --git a/rowers/forms.py b/rowers/forms.py index e9e4f31e..da1c5ed0 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -90,6 +90,24 @@ class UploadOptionsForm(forms.Form): class Meta: fields = ['make_plot','plottype','upload_toc2','makeprivate'] +# The form to indicate additional actions to be performed immediately +# after a successful upload. This version allows the Team manager to select +# a team member +class TeamUploadOptionsForm(forms.Form): + plotchoices = ( + ('timeplot','Time Plot'), + ('distanceplot','Distance Plot'), + ('pieplot','Pie Chart'), + ) + make_plot = forms.BooleanField(initial=False,required=False) + plottype = forms.ChoiceField(required=False, + choices=plotchoices, + initial='timeplot', + label='Plot Type') + + class Meta: + fields = ['make_plot','plottype'] + # This form is used on the Analysis page to add a custom distance/time # trial and predict the pace class PredictedPieceForm(forms.Form): diff --git a/rowers/templates/base.html b/rowers/templates/base.html index 13c4d985..8e6487a2 100644 --- a/rowers/templates/base.html +++ b/rowers/templates/base.html @@ -1,5 +1,6 @@ {% load cookielaw_tags %} {% load analytical %} +{% load rowerfilters %} @@ -143,14 +144,17 @@ {% endif %}
- {% if user.is_authenticated and teams %} + {% if user.is_authenticated and user|has_teams %}
- {% if user.is_authenticated and teams %} + {% if user.is_authenticated and user|user_teams %}