From 77798fe9992c9f3c9cdeef08a6208f684ff40e7e Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 22 Feb 2017 17:57:07 +0100 Subject: [PATCH] chart axes choice on multi compare view --- rowers/interactiveplots.py | 5 +- rowers/templates/list_workouts.html | 1 + rowers/templates/multicompare.html | 30 ++++++---- rowers/templates/team.html | 72 +++++++++++++---------- rowers/templates/team_compare_select.html | 14 +++-- rowers/templates/teambuttons.html | 9 +++ rowers/views.py | 44 ++++++++++++-- 7 files changed, 121 insertions(+), 54 deletions(-) create mode 100644 rowers/templates/teambuttons.html diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index ccc18ca7..42bd8d9e 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -891,7 +891,8 @@ def interactive_cum_flex_chart2(theworkouts,promember=0, yparamname1 = axlabels[yparam1] - yparamname2 = axlabels[yparam2] + if yparam2 != 'None': + yparamname2 = axlabels[yparam2] datadf = datadf[datadf[yparam1] > 0] @@ -1668,8 +1669,6 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line', if yparam != 'time' and yparam != 'pace': plot.add_layout(ylabel) - print cntr,id,len(group),ymean - source = ColumnDataSource( group ) diff --git a/rowers/templates/list_workouts.html b/rowers/templates/list_workouts.html index 33408fe0..b3b37262 100644 --- a/rowers/templates/list_workouts.html +++ b/rowers/templates/list_workouts.html @@ -35,6 +35,7 @@
{% if team %} + {% include "teambuttons.html" with teamid=team.id %}

{{ team.name }} Team Workouts

{% else %}

My Workouts

diff --git a/rowers/templates/multicompare.html b/rowers/templates/multicompare.html index c5724579..dfc5d717 100644 --- a/rowers/templates/multicompare.html +++ b/rowers/templates/multicompare.html @@ -34,25 +34,33 @@ -
+

Interactive Comparison

-
- Team Workouts +
+ {% include "teambuttons.html" with teamid=teamid%}
- -
- Team Page -
-
+
+
+
+ {% csrf_token %} + + {{ chartform.as_table }} +
+
+

+ +

+
+
+
+
{{ the_div|safe }}
-
+ {% endblock %} diff --git a/rowers/templates/team.html b/rowers/templates/team.html index 7315fe48..b045a4c5 100644 --- a/rowers/templates/team.html +++ b/rowers/templates/team.html @@ -5,30 +5,40 @@ {% block content %}

{{ team.name }}

-

{{ team.notes }}

-

Manager: {{ team.manager.first_name }} {{ team.manager.last_name }}

+
+ {% include "teambuttons.html" with teamid=team.id %} +
+
+

{{ team.notes }}

+

Manager: {{ team.manager.first_name }} {{ team.manager.last_name }}

+
+
+
{% if ismember %} - - {% if team.manager == user %} -
- Edit Team -
- {% else %} -
-

  -

- {% endif %} - {% elif hasrequested %} + + {% if team.manager == user %} +
+ Edit Team +
+ {% else %} +
+

  +

+ {% endif %} + {% elif hasrequested %}

You have requested access to this team

- {% else %} -
- Join - A request will be sent to the team manager + {% else %} +
+ Join + A request will be sent to the team manager + +
+ {% endif %} +
-
- {% endif %} +

Members

@@ -59,19 +69,19 @@
{% if team.manager == user %}

Use the form to add a new user. You can either select a user from the list of your existing club members who are not on this team yet, or you can type the user's email address, which also works for users who have not registered to the site yet.

- {% if inviteform.errors %} -

- Please correct the error{{ inviteform.errors|pluralize }} below. -

+ {% if inviteform.errors %} +

+ Please correct the error{{ inviteform.errors|pluralize }} below. +

{% endif %}
- - {{ inviteform.as_table }} -
- {% csrf_token %} -
+ + {{ inviteform.as_table }} +
+ {% csrf_token %} +
-
+
{% else %}

diff --git a/rowers/templates/team_compare_select.html b/rowers/templates/team_compare_select.html index cee206f8..d0f36f9a 100644 --- a/rowers/templates/team_compare_select.html +++ b/rowers/templates/team_compare_select.html @@ -8,8 +8,15 @@

- -
+
+ {% include "teambuttons.html" with teamid=teamid%} +
+
+
+

{{ team.name }} Team Workouts

+
+
+
{% if team %}
@@ -46,9 +53,6 @@
-
-

{{ team.name }} Team Workouts

-
diff --git a/rowers/templates/teambuttons.html b/rowers/templates/teambuttons.html new file mode 100644 index 00000000..b91e27c7 --- /dev/null +++ b/rowers/templates/teambuttons.html @@ -0,0 +1,9 @@ + + +
+ Team Page +
diff --git a/rowers/views.py b/rowers/views.py index e492a57c..7ef32f3a 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -2057,9 +2057,14 @@ def multi_compare_view(request): r = Rower.objects.get(user=request.user) result = request.user.is_authenticated() and ispromember(request.user) if result: - promember=1 + promember=1 - if request.method == 'POST': + if 'ids' in request.session: + print request.session['ids'] + + print request.POST + + if request.method == 'POST' and 'workouts' in request.POST: form = WorkoutMultipleCompareForm(request.POST) chartform = ChartParamChoiceForm(request.POST) if form.is_valid() and chartform.is_valid(): @@ -2070,6 +2075,8 @@ def multi_compare_view(request): plottype = chartform.cleaned_data['plottype'] teamid = chartform.cleaned_data['teamid'] ids = [int(w.id) for w in workouts] + request.session['ids'] = ids + labeldict = { int(w.id): w.__unicode__() for w in workouts } @@ -2086,9 +2093,40 @@ def multi_compare_view(request): 'the_div':div, 'promember':promember, 'teamid':teamid, + 'chartform':chartform, }) else: return HttpResponse("Form is not valid") + if request.method == 'POST' and 'ids' in request.session: + chartform = ChartParamChoiceForm(request.POST) + if chartform.is_valid(): + xparam = chartform.cleaned_data['xparam'] + yparam = chartform.cleaned_data['yparam'] + plottype = chartform.cleaned_data['plottype'] + teamid = chartform.cleaned_data['teamid'] + ids = request.session['ids'] + request.session['ids'] = ids + workouts = [Workout.objects.get(id=id) for id in ids] + + labeldict = { + int(w.id): w.__unicode__() for w in workouts + } + + res = interactive_multiple_compare_chart(ids,xparam,yparam, + promember=promember, + plottype=plottype, + labeldict=labeldict) + script = res[0] + div = res[1] + + return render(request,'multicompare.html', + {'interactiveplot':script, + 'the_div':div, + 'promember':promember, + 'teamid':teamid, + 'chartform':chartform, + }) + else: url = reverse(workouts_view) return HttpResponseRedirect(url) @@ -5625,8 +5663,6 @@ def rower_teams_view(request,message='',successmessage=''): myrequests = TeamRequest.objects.filter(team__in=myteams) myinvites = TeamInvite.objects.filter(team__in=myteams) - print form - return render(request, 'teams.html', { 'teams':ts,