Merge branch 'release/v6.88'
This commit is contained in:
@@ -522,30 +522,30 @@ class TrendFlexModalForm(forms.Form):
|
|||||||
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
||||||
label='Water Boat Type',
|
label='Water Boat Type',
|
||||||
initial = types.waterboattype)
|
initial = types.waterboattype)
|
||||||
|
rankingonly = forms.BooleanField(initial=False,
|
||||||
|
label='Only Ranking Pieces',
|
||||||
|
required=True)
|
||||||
|
|
||||||
|
|
||||||
# This form sets options for the summary stats page
|
# This form sets options for the summary stats page
|
||||||
class StatsOptionsForm(forms.Form):
|
class StatsOptionsForm(forms.Form):
|
||||||
includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
|
includereststrokes = forms.BooleanField(initial=False,label='Include Rest Strokes',required=False)
|
||||||
|
rankingonly = forms.BooleanField(initial=False,
|
||||||
|
label='Only Ranking Pieces',required=True)
|
||||||
water = forms.BooleanField(initial=False,required=False)
|
water = forms.BooleanField(initial=False,required=False)
|
||||||
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
waterboattype = forms.MultipleChoiceField(choices=boattypes,
|
||||||
label='Water Boat Type',
|
label='Water Boat Type',
|
||||||
widget=forms.CheckboxSelectMultiple(),
|
widget=forms.CheckboxSelectMultiple(),
|
||||||
initial = types.waterboattype)
|
initial = types.waterboattype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(StatsOptionsForm, self).__init__(*args,**kwargs)
|
super(StatsOptionsForm, self).__init__(*args,**kwargs)
|
||||||
|
|
||||||
for type in types.checktypes:
|
for type in types.checktypes:
|
||||||
self.fields[type] = forms.BooleanField(initial=True,required=False)
|
self.fields[type] = forms.BooleanField(initial=True,required=False)
|
||||||
|
|
||||||
# rower = forms.BooleanField(initial=True,required=False)
|
|
||||||
# dynamic = forms.BooleanField(initial=True,required=False)
|
|
||||||
# slides = forms.BooleanField(initial=True,required=False)
|
|
||||||
# skierg = forms.BooleanField(initial=False,required=False)
|
|
||||||
# paddle = forms.BooleanField(initial=False,required=False)
|
|
||||||
# snow = forms.BooleanField(initial=False,required=False)
|
|
||||||
# coastal = forms.BooleanField(initial=False,required=False)
|
|
||||||
# other = forms.BooleanField(initial=False,required=False)
|
|
||||||
|
|
||||||
class CourseSelectForm(forms.Form):
|
class CourseSelectForm(forms.Form):
|
||||||
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
|
course = forms.ModelChoiceField(queryset=GeoCourse.objects.all())
|
||||||
@@ -753,6 +753,65 @@ class RaceResultFilterForm(forms.Form):
|
|||||||
initial=['hwt','lwt'],
|
initial=['hwt','lwt'],
|
||||||
widget=forms.CheckboxSelectMultiple())
|
widget=forms.CheckboxSelectMultiple())
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
if 'records' in kwargs:
|
||||||
|
records = kwargs.pop('records',None)
|
||||||
|
|
||||||
|
super(RaceResultFilterForm,self).__init__(*args,**kwargs)
|
||||||
|
|
||||||
|
if records:
|
||||||
|
# sex
|
||||||
|
thesexes = [record.sex for record in records]
|
||||||
|
thesexes = list(set(thesexes))
|
||||||
|
|
||||||
|
if len(thesexes)<= 1:
|
||||||
|
del self.fields['sex']
|
||||||
|
else:
|
||||||
|
sexchoices = []
|
||||||
|
for choice in self.fields['sex'].choices:
|
||||||
|
if choice[0] in thesexes:
|
||||||
|
sexchoices.append(choice)
|
||||||
|
self.fields['sex'].choices = sexchoices
|
||||||
|
|
||||||
|
# boatclass
|
||||||
|
theboatclasses = [record.boatclass for record in records]
|
||||||
|
theboatclasses = list(set(theboatclasses))
|
||||||
|
|
||||||
|
if len(theboatclasses)<= 1:
|
||||||
|
del self.fields['boatclass']
|
||||||
|
else:
|
||||||
|
boatclasschoices = []
|
||||||
|
for choice in self.fields['boatclass'].choices:
|
||||||
|
if choice[0] in theboatclasses:
|
||||||
|
boatclasschoices.append(choice)
|
||||||
|
self.fields['boatclass'].choices = boatclasschoices
|
||||||
|
|
||||||
|
# boattype
|
||||||
|
theboattypees = [record.boattype for record in records]
|
||||||
|
theboattypees = list(set(theboattypees))
|
||||||
|
|
||||||
|
if len(theboattypees)<= 1:
|
||||||
|
del self.fields['boattype']
|
||||||
|
else:
|
||||||
|
boattypechoices = []
|
||||||
|
for choice in self.fields['boattype'].choices:
|
||||||
|
if choice[0] in theboattypees:
|
||||||
|
boattypechoices.append(choice)
|
||||||
|
self.fields['boattype'].choices = boattypechoices
|
||||||
|
|
||||||
|
# weightcategory
|
||||||
|
theweightcategoryes = [record.weightcategory for record in records]
|
||||||
|
theweightcategoryes = list(set(theweightcategoryes))
|
||||||
|
|
||||||
|
if len(theweightcategoryes)<= 1:
|
||||||
|
del self.fields['weightcategory']
|
||||||
|
else:
|
||||||
|
weightcategorychoices = []
|
||||||
|
for choice in self.fields['weightcategory'].choices:
|
||||||
|
if choice[0] in theweightcategoryes:
|
||||||
|
weightcategorychoices.append(choice)
|
||||||
|
self.fields['weightcategory'].choices = weightcategorychoices
|
||||||
|
|
||||||
class WorkoutRaceSelectForm(forms.Form):
|
class WorkoutRaceSelectForm(forms.Form):
|
||||||
# evaluate_after = forms.TimeField(
|
# evaluate_after = forms.TimeField(
|
||||||
# input_formats=['%H:%M:%S.%f',
|
# input_formats=['%H:%M:%S.%f',
|
||||||
|
|||||||
@@ -1641,10 +1641,11 @@ class VirtualRaceResult(models.Model):
|
|||||||
u1 = rr.user.first_name,
|
u1 = rr.user.first_name,
|
||||||
u2 = rr.user.last_name,
|
u2 = rr.user.last_name,
|
||||||
)
|
)
|
||||||
return u'Entry for {n} for "{r}" in {d}'.format(
|
return u'Entry for {n} for "{r}" in {c} {d}'.format(
|
||||||
n = name,
|
n = name,
|
||||||
r = self.race,
|
r = self.race,
|
||||||
d = self.boattype,
|
d = self.boattype,
|
||||||
|
c = self.boatclass,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,8 @@
|
|||||||
{{ coursescript|safe }}
|
{{ coursescript|safe }}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{% if form %}
|
||||||
<p>
|
<p>
|
||||||
<h2>Filter Results</h2>
|
<h2>Filter Results</h2>
|
||||||
|
|
||||||
@@ -253,6 +255,7 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input class="button green" type="submit" value="Submit">
|
<input class="button green" type="submit" value="Submit">
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
200
rowers/views.py
200
rowers/views.py
@@ -2969,6 +2969,7 @@ def cum_flex_data(
|
|||||||
request,
|
request,
|
||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
|
'rankingonly':False,
|
||||||
'workouttypes':[i[0] for i in types.workouttypes],
|
'workouttypes':[i[0] for i in types.workouttypes],
|
||||||
'waterboattype':types.waterboattype,
|
'waterboattype':types.waterboattype,
|
||||||
'theuser':0,
|
'theuser':0,
|
||||||
@@ -2984,6 +2985,7 @@ def cum_flex_data(
|
|||||||
options = request.session['options']
|
options = request.session['options']
|
||||||
|
|
||||||
workouttypes = options['workouttypes']
|
workouttypes = options['workouttypes']
|
||||||
|
rankingonly = options['rankingonly']
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
waterboattype = options['waterboattype']
|
waterboattype = options['waterboattype']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
@@ -3026,23 +3028,31 @@ def cum_flex_data(
|
|||||||
promember=1
|
promember=1
|
||||||
|
|
||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
|
|
||||||
|
if rankingonly:
|
||||||
|
rankingpiece = [True,]
|
||||||
|
else:
|
||||||
|
rankingpiece = [True,False]
|
||||||
|
|
||||||
allworkouts = Workout.objects.filter(user=r2,
|
allworkouts = Workout.objects.filter(user=r2,
|
||||||
workouttype__in=workouttypes,
|
workouttype__in=workouttypes,
|
||||||
boattype__in=waterboattype,
|
boattype__in=waterboattype,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate)
|
startdatetime__lte=enddate,
|
||||||
|
rankingpiece__in=rankingpiece)
|
||||||
|
|
||||||
if allworkouts:
|
if allworkouts:
|
||||||
res = interactive_cum_flex_chart2(allworkouts,xparam=xparam,
|
res = interactive_cum_flex_chart2(allworkouts,xparam=xparam,
|
||||||
yparam1=yparam1,
|
yparam1=yparam1,
|
||||||
yparam2=yparam2,
|
yparam2=yparam2,
|
||||||
promember=promember,
|
promember=promember,
|
||||||
workstrokesonly=workstrokesonly)
|
workstrokesonly=workstrokesonly,
|
||||||
|
rankingpiece__in=rankingpiece)
|
||||||
script = res[0]
|
script = res[0]
|
||||||
div = res[1]
|
div = res[1]
|
||||||
else:
|
else:
|
||||||
script = ''
|
script = ''
|
||||||
div = '<p>No erg pieces uploaded for this date range.</p>'
|
div = '<p>No pieces uploaded for this date range.</p>'
|
||||||
|
|
||||||
scripta = script.split('\n')[2:-1]
|
scripta = script.split('\n')[2:-1]
|
||||||
script = ''.join(scripta)
|
script = ''.join(scripta)
|
||||||
@@ -3070,7 +3080,8 @@ def cum_flex(request,theuser=0,
|
|||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'workouttypes':[i[0] for i in types.workouttypes],
|
'workouttypes':[i[0] for i in types.workouttypes],
|
||||||
'waterboattype':types.waterboattype
|
'waterboattype':types.waterboattype,
|
||||||
|
'rankingonly':False,
|
||||||
}):
|
}):
|
||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
@@ -3086,6 +3097,11 @@ def cum_flex(request,theuser=0,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
includereststrokes = False
|
includereststrokes = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
rankingonly = options['rankingonly']
|
||||||
|
except KeyError:
|
||||||
|
rankingonly = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
waterboattype = options['waterboattype']
|
waterboattype = options['waterboattype']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -3094,10 +3110,6 @@ def cum_flex(request,theuser=0,
|
|||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
|
|
||||||
# checktypes = ['water','rower','dynamic','slides','skierg',
|
|
||||||
# 'paddle','snow','coastal','other']
|
|
||||||
|
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
startdate = enddate-datetime.timedelta(days=int(deltadays))
|
||||||
|
|
||||||
@@ -3130,8 +3142,6 @@ def cum_flex(request,theuser=0,
|
|||||||
if result:
|
if result:
|
||||||
promember=1
|
promember=1
|
||||||
|
|
||||||
#if not promember:
|
|
||||||
#return HttpResponseRedirect("/rowers/about/")
|
|
||||||
|
|
||||||
# get all indoor rows of in date range
|
# get all indoor rows of in date range
|
||||||
|
|
||||||
@@ -3170,6 +3180,7 @@ def cum_flex(request,theuser=0,
|
|||||||
optionsform = StatsOptionsForm(request.POST)
|
optionsform = StatsOptionsForm(request.POST)
|
||||||
if optionsform.is_valid():
|
if optionsform.is_valid():
|
||||||
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
||||||
|
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
workouttypes = []
|
workouttypes = []
|
||||||
@@ -3182,6 +3193,7 @@ def cum_flex(request,theuser=0,
|
|||||||
'includereststrokes':includereststrokes,
|
'includereststrokes':includereststrokes,
|
||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
'waterboattype':waterboattype,
|
'waterboattype':waterboattype,
|
||||||
|
'rankingonly':rankingonly,
|
||||||
}
|
}
|
||||||
request.session['options'] = options
|
request.session['options'] = options
|
||||||
form = DateRangeForm(initial={
|
form = DateRangeForm(initial={
|
||||||
@@ -3216,7 +3228,7 @@ def cum_flex(request,theuser=0,
|
|||||||
# set options form correctly
|
# set options form correctly
|
||||||
initial = {}
|
initial = {}
|
||||||
initial['includereststrokes'] = includereststrokes
|
initial['includereststrokes'] = includereststrokes
|
||||||
|
initial['rankingonly'] = rankingonly
|
||||||
initial['waterboattype'] = waterboattype
|
initial['waterboattype'] = waterboattype
|
||||||
|
|
||||||
for wtype in types.checktypes:
|
for wtype in types.checktypes:
|
||||||
@@ -3235,6 +3247,7 @@ def cum_flex(request,theuser=0,
|
|||||||
|
|
||||||
|
|
||||||
options['includereststrokes'] = includereststrokes
|
options['includereststrokes'] = includereststrokes
|
||||||
|
options['rankingonly'] = includereststrokes
|
||||||
options['workouttypes'] =workouttypes
|
options['workouttypes'] =workouttypes
|
||||||
options['waterboattype'] =waterboattype
|
options['waterboattype'] =waterboattype
|
||||||
options['theuser'] =theuser
|
options['theuser'] =theuser
|
||||||
@@ -5730,6 +5743,11 @@ def user_multiflex_select(request,
|
|||||||
else:
|
else:
|
||||||
waterboattype = types.waterboattype
|
waterboattype = types.waterboattype
|
||||||
|
|
||||||
|
if 'rankingonly' in request.session:
|
||||||
|
rankingonly = request.session['rankingonly']
|
||||||
|
else:
|
||||||
|
rankingonly = False
|
||||||
|
|
||||||
|
|
||||||
if 'modalities' in request.session:
|
if 'modalities' in request.session:
|
||||||
modalities = request.session['modalities']
|
modalities = request.session['modalities']
|
||||||
@@ -5761,6 +5779,7 @@ def user_multiflex_select(request,
|
|||||||
if modalityform.is_valid():
|
if modalityform.is_valid():
|
||||||
modality = modalityform.cleaned_data['modality']
|
modality = modalityform.cleaned_data['modality']
|
||||||
waterboattype = modalityform.cleaned_data['waterboattype']
|
waterboattype = modalityform.cleaned_data['waterboattype']
|
||||||
|
rankingonly = modalityform.cleaned_data['rankingonly']
|
||||||
if modality == 'all':
|
if modality == 'all':
|
||||||
modalities = [m[0] for m in types.workouttypes]
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
else:
|
else:
|
||||||
@@ -5772,7 +5791,7 @@ def user_multiflex_select(request,
|
|||||||
|
|
||||||
request.session['modalities'] = modalities
|
request.session['modalities'] = modalities
|
||||||
request.session['waterboattype'] = waterboattype
|
request.session['waterboattype'] = waterboattype
|
||||||
|
request.session['rankingonly'] = rankingonly
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||||
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
||||||
@@ -5794,10 +5813,22 @@ def user_multiflex_select(request,
|
|||||||
if b[0] not in waterboattype:
|
if b[0] not in waterboattype:
|
||||||
negtypes.append(b[0])
|
negtypes.append(b[0])
|
||||||
|
|
||||||
workouts = Workout.objects.filter(user=r,
|
if rankingonly:
|
||||||
startdatetime__gte=startdate,
|
rankingpiece = [True]
|
||||||
startdatetime__lte=enddate,
|
else:
|
||||||
workouttype__in=modalities).order_by("-date", "-starttime").exclude(boattype__in=negtypes)
|
rankingpiece = [True,False]
|
||||||
|
|
||||||
|
workouts = Workout.objects.filter(
|
||||||
|
user=r,
|
||||||
|
startdatetime__gte=startdate,
|
||||||
|
startdatetime__lte=enddate,
|
||||||
|
workouttype__in=modalities,
|
||||||
|
rankingpiece__in=rankingpiece
|
||||||
|
).order_by(
|
||||||
|
"-date", "-starttime"
|
||||||
|
).exclude(
|
||||||
|
boattype__in=negtypes
|
||||||
|
)
|
||||||
|
|
||||||
query = request.GET.get('q')
|
query = request.GET.get('q')
|
||||||
if query:
|
if query:
|
||||||
@@ -6222,7 +6253,8 @@ def user_boxplot_select(request,
|
|||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'workouttypes':['rower','dynamic','slides'],
|
'workouttypes':['rower','dynamic','slides'],
|
||||||
'waterboattype':types.waterboattype
|
'waterboattype':types.waterboattype,
|
||||||
|
'rankingonly':False,
|
||||||
},
|
},
|
||||||
userid=0):
|
userid=0):
|
||||||
|
|
||||||
@@ -6238,6 +6270,11 @@ def user_boxplot_select(request,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
workouttypes = ['rower','dynamic','slides']
|
workouttypes = ['rower','dynamic','slides']
|
||||||
|
|
||||||
|
try:
|
||||||
|
rankingonly = options['rankingonly']
|
||||||
|
except KeyError:
|
||||||
|
rankingonly = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
includereststrokes = options['includereststrokes']
|
includereststrokes = options['includereststrokes']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -6246,8 +6283,6 @@ def user_boxplot_select(request,
|
|||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
# checktypes = ['water','rower','dynamic','slides','skierg',
|
|
||||||
# 'paddle','snow','other','coastal']
|
|
||||||
waterboattype = types.waterboattype
|
waterboattype = types.waterboattype
|
||||||
|
|
||||||
if 'startdate' in request.session:
|
if 'startdate' in request.session:
|
||||||
@@ -6295,6 +6330,7 @@ def user_boxplot_select(request,
|
|||||||
if optionsform.is_valid():
|
if optionsform.is_valid():
|
||||||
workouttypes = []
|
workouttypes = []
|
||||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
|
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||||
for type in types.checktypes:
|
for type in types.checktypes:
|
||||||
if optionsform.cleaned_data[type]:
|
if optionsform.cleaned_data[type]:
|
||||||
workouttypes.append(type)
|
workouttypes.append(type)
|
||||||
@@ -6302,6 +6338,7 @@ def user_boxplot_select(request,
|
|||||||
options = {
|
options = {
|
||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
'waterboattype':waterboattype,
|
'waterboattype':waterboattype,
|
||||||
|
'rankingonly':rankingonly,
|
||||||
}
|
}
|
||||||
request.session['options'] = options
|
request.session['options'] = options
|
||||||
|
|
||||||
@@ -6325,20 +6362,31 @@ def user_boxplot_select(request,
|
|||||||
if b[0] not in waterboattype:
|
if b[0] not in waterboattype:
|
||||||
negtypes.append(b[0])
|
negtypes.append(b[0])
|
||||||
|
|
||||||
|
if rankingonly:
|
||||||
|
rankingpiece = [True]
|
||||||
|
else:
|
||||||
|
rankingpiece = [True,False]
|
||||||
|
|
||||||
waterinclude = False
|
waterinclude = False
|
||||||
if 'water' in workouttypes:
|
|
||||||
waterinclude = True
|
for ttype in types.otwtypes:
|
||||||
|
if ttype in workouttypes:
|
||||||
|
waterinclude = True
|
||||||
|
|
||||||
|
if waterinclude:
|
||||||
workoutsw = Workout.objects.filter(user=r,
|
workoutsw = Workout.objects.filter(user=r,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype='water',
|
workouttype__in=types.otwtypes,
|
||||||
|
rankingpiece__in=rankingpiece,
|
||||||
).exclude(boattype__in=negtypes)
|
).exclude(boattype__in=negtypes)
|
||||||
workouttypes = [w for w in workouttypes if w != 'water']
|
workouttypes = [w for w in workouttypes if w not in types.otwtypes]
|
||||||
|
|
||||||
workoutse = Workout.objects.filter(user=r,
|
workoutse = Workout.objects.filter(user=r,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype__in=workouttypes)
|
workouttype__in=workouttypes,
|
||||||
|
rankingpiece__in=rankingpiece)
|
||||||
|
|
||||||
if waterinclude:
|
if waterinclude:
|
||||||
workouts = workoutse | workoutsw
|
workouts = workoutse | workoutsw
|
||||||
@@ -6347,9 +6395,8 @@ def user_boxplot_select(request,
|
|||||||
workouts = workoutse.order_by("-date","-starttime")
|
workouts = workoutse.order_by("-date","-starttime")
|
||||||
|
|
||||||
if waterinclude:
|
if waterinclude:
|
||||||
workouttypes.append('water')
|
for ttype in types.otwtypes:
|
||||||
|
workouttypes.append(ttype)
|
||||||
|
|
||||||
|
|
||||||
query = request.GET.get('q')
|
query = request.GET.get('q')
|
||||||
if query:
|
if query:
|
||||||
@@ -7710,7 +7757,8 @@ def cumstats(request,theuser=0,
|
|||||||
options={
|
options={
|
||||||
'includereststrokes':False,
|
'includereststrokes':False,
|
||||||
'workouttypes':['rower','dynamic','slides'],
|
'workouttypes':['rower','dynamic','slides'],
|
||||||
'waterboattype':types.waterboattype
|
'waterboattype':types.waterboattype,
|
||||||
|
'rankingonly':False,
|
||||||
}):
|
}):
|
||||||
|
|
||||||
if 'options' in request.session:
|
if 'options' in request.session:
|
||||||
@@ -7728,10 +7776,13 @@ def cumstats(request,theuser=0,
|
|||||||
includereststrokes = False
|
includereststrokes = False
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
rankingonly = options['rankingonly']
|
||||||
|
except KeyError:
|
||||||
|
rankingonly = False
|
||||||
|
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
|
|
||||||
# checktypes = ['water','rower','dynamic','slides','skierg',
|
|
||||||
# 'paddle','snow','other','coastal']
|
|
||||||
waterboattype = types.waterboattype
|
waterboattype = types.waterboattype
|
||||||
|
|
||||||
if deltadays>0:
|
if deltadays>0:
|
||||||
@@ -7807,6 +7858,7 @@ def cumstats(request,theuser=0,
|
|||||||
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
includereststrokes = optionsform.cleaned_data['includereststrokes']
|
||||||
workstrokesonly = not includereststrokes
|
workstrokesonly = not includereststrokes
|
||||||
workouttypes = []
|
workouttypes = []
|
||||||
|
rankingonly = optionsform.cleaned_data['rankingonly']
|
||||||
waterboattype = optionsform.cleaned_data['waterboattype']
|
waterboattype = optionsform.cleaned_data['waterboattype']
|
||||||
for type in types.checktypes:
|
for type in types.checktypes:
|
||||||
if optionsform.cleaned_data[type]:
|
if optionsform.cleaned_data[type]:
|
||||||
@@ -7816,6 +7868,7 @@ def cumstats(request,theuser=0,
|
|||||||
'includereststrokes':includereststrokes,
|
'includereststrokes':includereststrokes,
|
||||||
'workouttypes':workouttypes,
|
'workouttypes':workouttypes,
|
||||||
'waterboattype':waterboattype,
|
'waterboattype':waterboattype,
|
||||||
|
'rankingonly':rankingonly,
|
||||||
}
|
}
|
||||||
request.session['options'] = options
|
request.session['options'] = options
|
||||||
form = DateRangeForm()
|
form = DateRangeForm()
|
||||||
@@ -7833,21 +7886,32 @@ def cumstats(request,theuser=0,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
r2 = getrower(theuser)
|
r2 = getrower(theuser)
|
||||||
|
if rankingonly:
|
||||||
|
rankingpiece = [True]
|
||||||
|
else:
|
||||||
|
rankingpiece = [True,False]
|
||||||
|
|
||||||
waterinclude = False
|
waterinclude = False
|
||||||
if 'water' in workouttypes:
|
|
||||||
waterinclude = True
|
for ttype in types.otwtypes:
|
||||||
|
if ttype in workouttypes:
|
||||||
|
waterinclude = True
|
||||||
|
|
||||||
|
if waterinclude:
|
||||||
workoutsw = Workout.objects.filter(user=r2,
|
workoutsw = Workout.objects.filter(user=r2,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype='water',
|
workouttype='water',
|
||||||
boattype__in='waterboattype'
|
boattype__in='waterboattype',
|
||||||
|
rankingpiece__in=rankingpiece,
|
||||||
)
|
)
|
||||||
workouttypes = [w for w in workouttypes if w != 'water']
|
workouttypes = [w for w in workouttypes if w != 'water']
|
||||||
|
|
||||||
workoutse = Workout.objects.filter(user=r2,
|
workoutse = Workout.objects.filter(user=r2,
|
||||||
startdatetime__gte=startdate,
|
startdatetime__gte=startdate,
|
||||||
startdatetime__lte=enddate,
|
startdatetime__lte=enddate,
|
||||||
workouttype__in=workouttypes)
|
workouttype__in=workouttypes,
|
||||||
|
rankingpiece__in=rankingpiece)
|
||||||
|
|
||||||
if waterinclude:
|
if waterinclude:
|
||||||
allergworkouts = workoutse | workoutsw
|
allergworkouts = workoutse | workoutsw
|
||||||
@@ -7856,7 +7920,9 @@ def cumstats(request,theuser=0,
|
|||||||
allergworkouts = workoutse.order_by("-date","-starttime")
|
allergworkouts = workoutse.order_by("-date","-starttime")
|
||||||
|
|
||||||
if waterinclude:
|
if waterinclude:
|
||||||
workouttypes.append('water')
|
for ttype in types.otwtypes:
|
||||||
|
workouttypes.append(ttype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
@@ -10614,6 +10680,7 @@ def workout_upload_view(request,
|
|||||||
else:
|
else:
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|
||||||
|
|
||||||
if landingpage != 'workout_upload_view':
|
if landingpage != 'workout_upload_view':
|
||||||
url = reverse(landingpage,
|
url = reverse(landingpage,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
@@ -13634,6 +13701,11 @@ def virtualevent_view(request,id=0):
|
|||||||
|
|
||||||
script,div = course_map(race.course)
|
script,div = course_map(race.course)
|
||||||
|
|
||||||
|
|
||||||
|
records = VirtualRaceResult.objects.filter(
|
||||||
|
race=race
|
||||||
|
)
|
||||||
|
|
||||||
buttons = []
|
buttons = []
|
||||||
|
|
||||||
if not request.user.is_anonymous():
|
if not request.user.is_anonymous():
|
||||||
@@ -13656,15 +13728,31 @@ def virtualevent_view(request,id=0):
|
|||||||
buttons += ['editbutton']
|
buttons += ['editbutton']
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = RaceResultFilterForm(request.POST)
|
form = RaceResultFilterForm(request.POST,records=records)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
sex = cd['sex']
|
try:
|
||||||
boattype = cd['boattype']
|
sex = cd['sex']
|
||||||
boatclass = cd['boatclass']
|
except KeyError:
|
||||||
|
sex = ['female','male','mixed']
|
||||||
|
|
||||||
|
try:
|
||||||
|
boattype = cd['boattype']
|
||||||
|
except KeyError:
|
||||||
|
boattype = types.waterboattype
|
||||||
|
|
||||||
|
try:
|
||||||
|
boatclass = cd['boatclass']
|
||||||
|
except KeyError:
|
||||||
|
boatclass = [t for t in types.otwtypes]
|
||||||
|
|
||||||
age_min = cd['age_min']
|
age_min = cd['age_min']
|
||||||
age_max = cd['age_max']
|
age_max = cd['age_max']
|
||||||
weightcategory = cd['weightcategory']
|
|
||||||
|
try:
|
||||||
|
weightcategory = cd['weightcategory']
|
||||||
|
except KeyError:
|
||||||
|
weightcategory = ['hwt','lwt']
|
||||||
|
|
||||||
results = VirtualRaceResult.objects.filter(
|
results = VirtualRaceResult.objects.filter(
|
||||||
race=race,
|
race=race,
|
||||||
@@ -13691,13 +13779,16 @@ def virtualevent_view(request,id=0):
|
|||||||
age__lte=age_max
|
age__lte=age_max
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
form = RaceResultFilterForm()
|
|
||||||
|
|
||||||
results = VirtualRaceResult.objects.filter(
|
results = VirtualRaceResult.objects.filter(
|
||||||
race=race,
|
race=race,
|
||||||
workoutid__isnull=False,
|
workoutid__isnull=False,
|
||||||
).order_by("duration")
|
).order_by("duration")
|
||||||
|
|
||||||
|
if results:
|
||||||
|
form = RaceResultFilterForm(records=records)
|
||||||
|
else:
|
||||||
|
form = None
|
||||||
|
|
||||||
# to-do - add DNS
|
# to-do - add DNS
|
||||||
dns = []
|
dns = []
|
||||||
if timezone.now() > race.evaluation_closure:
|
if timezone.now() > race.evaluation_closure:
|
||||||
@@ -13708,10 +13799,6 @@ def virtualevent_view(request,id=0):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
records = VirtualRaceResult.objects.filter(
|
|
||||||
race=race
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
return render(request,'virtualevent.html',
|
return render(request,'virtualevent.html',
|
||||||
{
|
{
|
||||||
@@ -13801,14 +13888,25 @@ def virtualevent_addboat_view(request,id=0):
|
|||||||
sex = 'male'
|
sex = 'male'
|
||||||
|
|
||||||
if boattype in boattypes and boatclass in boatclasses:
|
if boattype in boattypes and boatclass in boatclasses:
|
||||||
messages.error(request,"You have already registered in that boat class/type")
|
# check if different sexes
|
||||||
url = reverse(virtualevent_view,
|
therecords = records.filter(
|
||||||
kwargs = {
|
boattype=boattype,
|
||||||
'id': race.id
|
boatclass=boatclass)
|
||||||
|
|
||||||
|
thesexes = [record.sex for record in therecords]
|
||||||
|
if sex in thesexes:
|
||||||
|
|
||||||
|
messages.error(
|
||||||
|
request,
|
||||||
|
"You have already registered in that boat class/type"
|
||||||
|
)
|
||||||
|
url = reverse(virtualevent_view,
|
||||||
|
kwargs = {
|
||||||
|
'id': race.id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
record = VirtualRaceResult(
|
record = VirtualRaceResult(
|
||||||
userid=r.id,
|
userid=r.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user