diff --git a/rowers/templates/.#cum_flex.html b/rowers/templates/.#cum_flex.html
deleted file mode 100644
index 01488739..00000000
--- a/rowers/templates/.#cum_flex.html
+++ /dev/null
@@ -1 +0,0 @@
-E408191@CZ27LT9RCGN72.648792:1509824931
\ No newline at end of file
diff --git a/rowers/templates/multiflex.html b/rowers/templates/multiflex.html
index 62666379..375602ea 100644
--- a/rowers/templates/multiflex.html
+++ b/rowers/templates/multiflex.html
@@ -11,7 +11,9 @@
Bokeh.set_log_level("info");
-{{ interactiveplot |safe }}
+
+
+
+
+
+
{% endblock %}
diff --git a/rowers/urls.py b/rowers/urls.py
index ce1d4045..9179e415 100644
--- a/rowers/urls.py
+++ b/rowers/urls.py
@@ -169,14 +169,10 @@ urlpatterns = [
url(r'^flexall/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)$',views.cum_flex),
url(r'^flexall/$',views.cum_flex),
- url(r'^(?P\d+)/flexalldata/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)$',views.cum_flex_data),
- url(r'^flexalldata/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)$',views.cum_flex_data),
- url(r'^flexalldata/(?P\w+.*)/(?P\w+.*)/(?P\w+.*)$',views.cum_flex_data),
url(r'^flexalldata/$',views.cum_flex_data),
url(r'^histo/u/(?P\d+)$',views.histo),
url(r'^flexall/u/(?P\d+)$',views.cum_flex),
- url(r'^flexalldata/u/(?P\d+)$',views.cum_flex_data),
url(r'^(?P\d+)/histo/(?P\w+.*)/(?P\w+.*)$',views.histo),
url(r'^(?P\d+)/histo/(?P\d+)$',views.histo),
url(r'^histo/(?P\w+.*)/(?P\w+.*)$',views.histo),
@@ -300,6 +296,7 @@ urlpatterns = [
url(r'^user-multiflex/(?P\d+)$',views.multiflex_view),
url(r'^user-multiflex/$',views.multiflex_view),
url(r'^user-multiflex$',views.multiflex_view),
+ url(r'^user-multiflex-data$',views.multiflex_data),
url(r'^me/teams/$',views.rower_teams_view),
url(r'^me/calcdps/$',views.rower_calcdps_view),
url(r'^me/exportsettings/$',views.rower_exportsettings_view),
diff --git a/rowers/utils.py b/rowers/utils.py
index fb44c219..921c8491 100644
--- a/rowers/utils.py
+++ b/rowers/utils.py
@@ -57,6 +57,32 @@ defaultleft = [
'panel_staticchart.html',
]
+coxes_calls = [
+ 'Sit Ready!',
+ "Let's relax the shoulders, and give me a power ten to the finish!",
+ "Almost there. Give me ten strokes on the legs!",
+ "Let it run!",
+ ]
+
+info_calls = [
+ "Please give us a minute to count all those strokes, you've been working hard!",
+ "Please give us a minute to count all your strokes."
+ ]
+
+import random
+
+def get_call():
+ call1 = random.choice(coxes_calls)
+ call2 = random.choice(info_calls)
+
+ call = """
+""" % (call1, call2)
+
+ return call
def absolute(request):
urls = {
diff --git a/rowers/views.py b/rowers/views.py
index acf55c49..98dc618b 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -700,7 +700,7 @@ def splitstdata(lijst):
from utils import (
geo_distance,serialize_list,deserialize_list,uniqify,
- str2bool,range_to_color_hex,absolute,myqueue
+ str2bool,range_to_color_hex,absolute,myqueue,get_call
)
import datautils
@@ -2558,10 +2558,15 @@ def cum_flex_data(
deltadays = options['deltadays']
+ try:
+ startdate = iso8601.parse_date(startdatestring)
+ except ParseError:
+ startdate = timezone.now()-datetime.timedelta(days=7)
- startdate = iso8601.parse_date(startdatestring)
-
- enddate = iso8601.parse_date(enddatestring)
+ try:
+ enddate = iso8601.parse_date(enddatestring)
+ except ParseError:
+ enddate = timezone.now()
if deltadays>0:
startdate = enddate-datetime.timedelta(days=int(deltadays))
@@ -2741,15 +2746,7 @@ def cum_flex(request,theuser=0,
optionsform = StatsOptionsForm()
script = ''
- div = """
-
-
-
- Sit Ready! We're counting strokes and loading data
-
-
-
-"""
+ div = get_call()
js_resources = ''
css_resources = ''
@@ -4445,10 +4442,22 @@ def user_multiflex_select(request,
})
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
-def multiflex_view(request,userid=0,
+def multiflex_data(request,userid=0,
options={
'includereststrokes':False,
'ploterrorbars':False,
+ 'userid':0,
+ 'palette': 'monochrome_blue',
+ 'groupby': 'spm',
+ 'binsize': 1,
+ 'xparam': 'hr',
+ 'yparam': 'pace',
+ 'spmmin': 15,
+ 'spmmax': 55,
+ 'workmin': 400,
+ 'workmax': 1500,
+ 'ids': [],
+ 'ploterrorbars':False,
}):
if 'options' in request.session:
@@ -4473,90 +4482,23 @@ def multiflex_view(request,userid=0,
if userid==0:
userid = request.user.id
+
+ palette = options['palette']
+ groupby = options['groupby']
+ binsize = options['binsize']
+ xparam = options['xparam']
+ yparam = options['yparam']
+ spmmin = options['spmmin']
+ spmmax = options['spmmax']
+ workmin = options['workmin']
+ workmax = options['workmax']
+ ids = options['ids']
+
+ workouts = [Workout.objects.get(id=id) for id in ids]
+ labeldict = {
+ int(w.id): w.__unicode__() for w in workouts
+ }
- if request.method == 'POST' and 'workouts' in request.POST:
- form = WorkoutMultipleCompareForm(request.POST)
- chartform = MultiFlexChoiceForm(request.POST)
- if form.is_valid() and chartform.is_valid():
- cd = form.cleaned_data
- workouts = cd['workouts']
- xparam = chartform.cleaned_data['xparam']
- yparam = chartform.cleaned_data['yparam']
- includereststrokes = chartform.cleaned_data['includereststrokes']
- ploterrorbars = chartform.cleaned_data['ploterrorbars']
- request.session['ploterrorbars'] = ploterrorbars
- request.session['includereststrokes'] = includereststrokes
- workstrokesonly = not includereststrokes
- palette = chartform.cleaned_data['palette']
- request.session['palette'] = palette
-
- groupby = chartform.cleaned_data['groupby']
- binsize = chartform.cleaned_data['binsize']
- if binsize <= 0:
- binsize = 1
- if groupby == 'pace':
- binsize *= 1000
-
- spmmin = chartform.cleaned_data['spmmin']
- spmmax = chartform.cleaned_data['spmmax']
- workmin = chartform.cleaned_data['workmin']
- workmax = chartform.cleaned_data['workmax']
-
- ids = [int(w.id) for w in workouts]
- request.session['ids'] = ids
-
- else:
- return HttpResponse("Form is not valid")
- elif request.method == 'POST' and 'ids' in request.session:
- chartform = MultiFlexChoiceForm(request.POST)
- if chartform.is_valid():
- xparam = chartform.cleaned_data['xparam']
- yparam = chartform.cleaned_data['yparam']
- includereststrokes = chartform.cleaned_data['includereststrokes']
- ploterrorbars = chartform.cleaned_data['ploterrorbars']
- request.session['ploterrorbars'] = ploterrorbars
- request.session['includereststrokes'] = includereststrokes
- workstrokesonly = not includereststrokes
- palette = chartform.cleaned_data['palette']
- request.session['palette'] = palette
-
- groupby = chartform.cleaned_data['groupby']
- binsize = chartform.cleaned_data['binsize']
- if binsize <= 0:
- binsize = 1
- if groupby == 'pace':
- binsize *= 1000.
-
- spmmin = chartform.cleaned_data['spmmin']
- spmmax = chartform.cleaned_data['spmmax']
- workmin = chartform.cleaned_data['workmin']
- workmax = chartform.cleaned_data['workmax']
-
- ids = request.session['ids']
- request.session['ids'] = ids
- workouts = dataprep.get_workouts(ids,userid)
- if not workouts:
- message = 'Error: Workouts in session storage do not belong to this user.'
- messages.error(request,message)
- url = reverse(user_multiflex_select,
- kwargs={
- 'userid':userid,
- }
- )
- return HttpResponseRedirect(url)
-
- # workouts = [Workout.objects.get(id=id) for id in ids]
-
- labeldict = {
- int(w.id): w.__unicode__() for w in workouts
- }
-
- else:
- return HttpResponse("invalid form")
- else:
- url = reverse(user_multiflex_select)
- return HttpResponseRedirect(url)
-
fieldlist,fielddict = dataprep.getstatsfields()
fieldlist = [xparam,yparam,groupby,
'workoutid','spm','driveenergy',
@@ -4712,10 +4654,145 @@ def multiflex_view(request,userid=0,
binsize=binsize,
colorlegend=colorlegend)
+ scripta= script.split('\n')[2:-1]
+ script = ''.join(scripta)
+
+
+ return JSONResponse({
+ "script":script,
+ "div":div,
+ })
+
+
+@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
+def multiflex_view(request,userid=0,
+ options={
+ 'includereststrokes':False,
+ 'ploterrorbars':False,
+ }):
+
+ if 'options' in request.session:
+ options = request.session['options']
+
+ try:
+ includereststrokes = options['includereststrokes']
+ except KeyError:
+ includereststrokes = False
+
+ try:
+ ploterrorbars = options['ploterrorbars']
+ except KeyError:
+ ploterrorbars = False
+
+ try:
+ palette = request.session['palette']
+ except KeyError:
+ palette = 'monochrome_blue'
+
+ workstrokesonly = not includereststrokes
+
+ if userid==0:
+ userid = request.user.id
+
+ if request.method == 'POST' and 'workouts' in request.POST:
+ form = WorkoutMultipleCompareForm(request.POST)
+ chartform = MultiFlexChoiceForm(request.POST)
+ if form.is_valid() and chartform.is_valid():
+ cd = form.cleaned_data
+ workouts = cd['workouts']
+ xparam = chartform.cleaned_data['xparam']
+ yparam = chartform.cleaned_data['yparam']
+ includereststrokes = chartform.cleaned_data['includereststrokes']
+ ploterrorbars = chartform.cleaned_data['ploterrorbars']
+
+ workstrokesonly = not includereststrokes
+ palette = chartform.cleaned_data['palette']
+
+ groupby = chartform.cleaned_data['groupby']
+ binsize = chartform.cleaned_data['binsize']
+ if binsize <= 0:
+ binsize = 1
+ if groupby == 'pace':
+ binsize *= 1000
+
+ spmmin = chartform.cleaned_data['spmmin']
+ spmmax = chartform.cleaned_data['spmmax']
+ workmin = chartform.cleaned_data['workmin']
+ workmax = chartform.cleaned_data['workmax']
+
+ ids = [int(w.id) for w in workouts]
+ request.session['ids'] = ids
+
+ else:
+ return HttpResponse("Form is not valid")
+ elif request.method == 'POST' and 'ids' in request.session:
+ chartform = MultiFlexChoiceForm(request.POST)
+ if chartform.is_valid():
+ xparam = chartform.cleaned_data['xparam']
+ yparam = chartform.cleaned_data['yparam']
+ includereststrokes = chartform.cleaned_data['includereststrokes']
+ ploterrorbars = chartform.cleaned_data['ploterrorbars']
+ request.session['ploterrorbars'] = ploterrorbars
+ request.session['includereststrokes'] = includereststrokes
+ workstrokesonly = not includereststrokes
+ palette = chartform.cleaned_data['palette']
+
+ groupby = chartform.cleaned_data['groupby']
+ binsize = chartform.cleaned_data['binsize']
+ if binsize <= 0:
+ binsize = 1
+ if groupby == 'pace':
+ binsize *= 1000.
+
+ spmmin = chartform.cleaned_data['spmmin']
+ spmmax = chartform.cleaned_data['spmmax']
+ workmin = chartform.cleaned_data['workmin']
+ workmax = chartform.cleaned_data['workmax']
+
+ ids = request.session['ids']
+ request.session['ids'] = ids
+ workouts = dataprep.get_workouts(ids,userid)
+ if not workouts:
+ message = 'Error: Workouts in session storage do not belong to this user.'
+ messages.error(request,message)
+ url = reverse(user_multiflex_select,
+ kwargs={
+ 'userid':userid,
+ }
+ )
+ return HttpResponseRedirect(url)
+
+ # workouts = [Workout.objects.get(id=id) for id in ids]
+
+
+ else:
+ return HttpResponse("invalid form")
+ else:
+ url = reverse(user_multiflex_select)
+ return HttpResponseRedirect(url)
+
+ div = get_call()
+
+ options['includereststrokes'] = includereststrokes
+ options['ploterrorbars'] = ploterrorbars
+ options['userid'] = userid
+ options['palette'] = palette
+ options['groupby'] = groupby
+ options['binsize'] = binsize
+ options['xparam'] = xparam
+ options['yparam'] = yparam
+ options['spmmin'] = spmmin
+ options['spmmax'] = spmmax
+ options['workmin'] = workmin
+ options['workmax'] = workmax
+ options['ids'] = ids
+
+
+ request.session['options'] = options
return render(request,'multiflex.html',
- {'interactiveplot':script,
+ {'interactiveplot':'',
'the_div':div,
'chartform':chartform,
'userid':userid,
@@ -4885,6 +4962,7 @@ def boxplot_view_data(request,userid=0,
ids = options['ids']
userid = options['userid']
plotfield = options['plotfield']
+
workstrokesonly = not includereststrokes
@@ -5004,15 +5082,7 @@ def boxplot_view(request,userid=0,
url = reverse(user_boxplot_select)
return HttpResponseRedirect(url)
- div = """
-
-
-
- Sit Ready! We're counting strokes and loading data
-
-
-
-"""
+ div = get_call()
options['spmmin'] = spmmin
options['spmmax'] = spmmax
diff --git a/static/css/rowsandall.css b/static/css/rowsandall.css
index 7be4294f..0188e56f 100644
--- a/static/css/rowsandall.css
+++ b/static/css/rowsandall.css
@@ -98,6 +98,14 @@ th {
font-weight: bold;
}
+cox {
+/* font-family: Georgia, serif; */
+ font-weight: normal;
+/* padding-top: 20px; */
+ text-align: center;
+ font-size: 2em;
+}
+
.listtable tbody tr:nth-of-type(even) { background-color: #DDD; }
.listtable thead th {
font-weight: bold;