passes checks in python3
This commit is contained in:
178
rowers/forms.py
178
rowers/forms.py
@@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from django import forms
|
||||
from django.contrib.admin.widgets import FilteredSelectMultiple
|
||||
from rowers.models import (
|
||||
@@ -9,15 +10,16 @@ from rowers.rows import validate_file_extension,must_be_csv,validate_image_exten
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.admin.widgets import AdminDateWidget
|
||||
from django.forms.extras.widgets import SelectDateWidget
|
||||
from django.forms.widgets import SelectDateWidget
|
||||
#from django.forms.extras.widgets import SelectDateWidget
|
||||
from django.utils import timezone,translation
|
||||
from django.forms import ModelForm, Select
|
||||
import dataprep
|
||||
import mytypes
|
||||
import rowers.dataprep as dataprep
|
||||
import rowers.mytypes as mytypes
|
||||
import datetime
|
||||
from django.forms import formset_factory
|
||||
from utils import landingpages
|
||||
from metrics import axes
|
||||
from rowers.utils import landingpages
|
||||
from rowers.metrics import axes
|
||||
|
||||
class FlexibleDecimalField(forms.DecimalField):
|
||||
|
||||
@@ -84,7 +86,7 @@ for key, value in disqualificationreasons:
|
||||
class DisqualificationForm(forms.Form):
|
||||
|
||||
reason = forms.ChoiceField(required=True,
|
||||
choices=disqualificationreasons,
|
||||
choices=disqualificationreasons,
|
||||
widget = forms.RadioSelect,)
|
||||
|
||||
message = forms.CharField(required=True,widget=forms.Textarea)
|
||||
@@ -139,10 +141,10 @@ class CourseForm(forms.Form):
|
||||
class DocumentsForm(forms.Form):
|
||||
title = forms.CharField(required=False)
|
||||
file = forms.FileField(required=False,
|
||||
validators=[validate_file_extension])
|
||||
validators=[validate_file_extension])
|
||||
|
||||
workouttype = forms.ChoiceField(required=True,
|
||||
choices=Workout.workouttypes)
|
||||
choices=Workout.workouttypes)
|
||||
|
||||
boattype = forms.ChoiceField(required=True,
|
||||
choices=mytypes.boattypes,
|
||||
@@ -150,19 +152,19 @@ class DocumentsForm(forms.Form):
|
||||
|
||||
|
||||
notes = forms.CharField(required=False,
|
||||
widget=forms.Textarea)
|
||||
widget=forms.Textarea)
|
||||
|
||||
offline = forms.BooleanField(initial=False,required=False,
|
||||
label='Process in Background')
|
||||
class Meta:
|
||||
fields = ['title','file','workouttype','boattype','fileformat','offline']
|
||||
fields = ['title','file','workouttype','boattype','fileformat','offline']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
from django.forms.widgets import HiddenInput
|
||||
super(DocumentsForm, self).__init__(*args, **kwargs)
|
||||
# self.fields['offline'].widget = HiddenInput()
|
||||
|
||||
from utils import (
|
||||
from rowers.utils import (
|
||||
workflowleftpanel,workflowmiddlepanel,
|
||||
defaultleft,defaultmiddle
|
||||
)
|
||||
@@ -267,14 +269,14 @@ class LandingPageForm(forms.Form):
|
||||
|
||||
class UploadOptionsForm(forms.Form):
|
||||
plotchoices = (
|
||||
('timeplot','Time Plot'),
|
||||
('distanceplot','Distance Plot'),
|
||||
('pieplot','Heart Rate Pie Chart'),
|
||||
)
|
||||
('timeplot','Time Plot'),
|
||||
('distanceplot','Distance Plot'),
|
||||
('pieplot','Heart Rate Pie Chart'),
|
||||
)
|
||||
make_plot = forms.BooleanField(initial=False,required=False)
|
||||
plottype = forms.ChoiceField(required=False,
|
||||
choices=plotchoices,
|
||||
initial='timeplot',
|
||||
choices=plotchoices,
|
||||
initial='timeplot',
|
||||
label='Plot Type')
|
||||
upload_to_C2 = forms.BooleanField(initial=False,required=False,
|
||||
label='Export to Concept2 logbook')
|
||||
@@ -303,7 +305,7 @@ class UploadOptionsForm(forms.Form):
|
||||
label='After Upload, go to')
|
||||
|
||||
class Meta:
|
||||
fields = ['make_plot','plottype','upload_toc2','makeprivate']
|
||||
fields = ['make_plot','plottype','upload_toc2','makeprivate']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.request = kwargs.pop('request',None)
|
||||
@@ -332,18 +334,18 @@ class UploadOptionsForm(forms.Form):
|
||||
# a team member
|
||||
class TeamUploadOptionsForm(forms.Form):
|
||||
plotchoices = (
|
||||
('timeplot','Time Plot'),
|
||||
('distanceplot','Distance Plot'),
|
||||
('pieplot','Pie Chart'),
|
||||
)
|
||||
('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',
|
||||
choices=plotchoices,
|
||||
initial='timeplot',
|
||||
label='Plot Type')
|
||||
|
||||
class Meta:
|
||||
fields = ['make_plot','plottype']
|
||||
fields = ['make_plot','plottype']
|
||||
|
||||
# This form is used on the Workout Split page
|
||||
class WorkoutSplitForm(forms.Form):
|
||||
@@ -392,9 +394,9 @@ class OteWorkoutTypeForm(forms.Form):
|
||||
|
||||
class PredictedPieceForm(forms.Form):
|
||||
unitchoices = (
|
||||
('t','minutes'),
|
||||
('d','meters'),
|
||||
)
|
||||
('t','minutes'),
|
||||
('d','meters'),
|
||||
)
|
||||
|
||||
rankingdistancechoices = []
|
||||
rankingdurationchoices = []
|
||||
@@ -422,10 +424,10 @@ class PredictedPieceForm(forms.Form):
|
||||
|
||||
value = forms.FloatField(initial=10,label='Free ranking piece (minutes)')
|
||||
pieceunit = forms.ChoiceField(required=True,choices=unitchoices,
|
||||
initial='t',label='Unit')
|
||||
initial='t',label='Unit')
|
||||
|
||||
class Meta:
|
||||
fields = ['value','pieceunit']
|
||||
fields = ['value','pieceunit']
|
||||
|
||||
class PredictedPieceFormNoDistance(forms.Form):
|
||||
|
||||
@@ -450,76 +452,76 @@ class PredictedPieceFormNoDistance(forms.Form):
|
||||
# On the Geeky side, to update stream information for river dwellers
|
||||
class UpdateStreamForm(forms.Form):
|
||||
unitchoices = (
|
||||
('m','m/s'),
|
||||
('f','foot/s'),
|
||||
('k','knots'),
|
||||
('p','pace difference (sec/500m)'),
|
||||
)
|
||||
('m','m/s'),
|
||||
('f','foot/s'),
|
||||
('k','knots'),
|
||||
('p','pace difference (sec/500m)'),
|
||||
)
|
||||
dist1 = forms.FloatField(initial=0,label = 'Distance 1')
|
||||
dist2 = forms.FloatField(initial=1000,label = 'Distance 2')
|
||||
stream1 = forms.FloatField(initial=0,label = 'Stream velocity 1')
|
||||
stream2 = forms.FloatField(initial=0,label = 'Stream velocity 2')
|
||||
streamunit = forms.ChoiceField(required=True,
|
||||
choices=unitchoices,
|
||||
initial='m',
|
||||
label='Unit')
|
||||
choices=unitchoices,
|
||||
initial='m',
|
||||
label='Unit')
|
||||
|
||||
class Meta:
|
||||
fields = ['dist1','dist2','stream1', 'stream2','streamunit']
|
||||
fields = ['dist1','dist2','stream1', 'stream2','streamunit']
|
||||
|
||||
# add wind information to your workout
|
||||
class UpdateWindForm(forms.Form):
|
||||
unitchoices = (
|
||||
('m','m/s'),
|
||||
('k','knots'),
|
||||
('b','beaufort'),
|
||||
('kmh','km/h'),
|
||||
('mph','miles/hour'),
|
||||
)
|
||||
('m','m/s'),
|
||||
('k','knots'),
|
||||
('b','beaufort'),
|
||||
('kmh','km/h'),
|
||||
('mph','miles/hour'),
|
||||
)
|
||||
dist1 = forms.FloatField(initial=0,label = 'Distance 1')
|
||||
dist2 = forms.FloatField(initial=1000,label = 'Distance 2')
|
||||
vwind1 = forms.FloatField(initial=0,required=False,label = 'Wind Speed 1')
|
||||
vwind2 = forms.FloatField(initial=0,required=False,label = 'Wind Speed 2')
|
||||
windunit = forms.ChoiceField(required=True,
|
||||
choices=unitchoices,
|
||||
initial='m',
|
||||
label='Unit')
|
||||
choices=unitchoices,
|
||||
initial='m',
|
||||
label='Unit')
|
||||
winddirection1 = forms.IntegerField(initial=0,required=False,
|
||||
label = 'Wind Direction 1')
|
||||
label = 'Wind Direction 1')
|
||||
winddirection2 = forms.IntegerField(initial=0,required=False,
|
||||
label = 'Wind Direction 2')
|
||||
label = 'Wind Direction 2')
|
||||
|
||||
class Meta:
|
||||
fields = ['dist1','dist2',
|
||||
'vwind1','vwind2',
|
||||
'windunit',
|
||||
'winddirection1','winddirection2']
|
||||
fields = ['dist1','dist2',
|
||||
'vwind1','vwind2',
|
||||
'windunit',
|
||||
'winddirection1','winddirection2']
|
||||
|
||||
# Form to select a data range to show workouts from a certain time period
|
||||
class DateRangeForm(forms.Form):
|
||||
startdate = forms.DateField(
|
||||
initial=timezone.now()-datetime.timedelta(days=365),
|
||||
# widget=SelectDateWidget(years=range(1990,2050)),
|
||||
# widget=SelectDateWidget(years=range(1990,2050)),
|
||||
widget=AdminDateWidget(),
|
||||
label='Start Date')
|
||||
label='Start Date')
|
||||
enddate = forms.DateField(
|
||||
initial=timezone.now(),
|
||||
widget=AdminDateWidget(),
|
||||
label='End Date')
|
||||
label='End Date')
|
||||
|
||||
class Meta:
|
||||
fields = ['startdate','enddate']
|
||||
fields = ['startdate','enddate']
|
||||
|
||||
class FitnessMetricForm(forms.Form):
|
||||
startdate = forms.DateField(
|
||||
initial=timezone.now()-datetime.timedelta(days=365),
|
||||
# widget=SelectDateWidget(years=range(1990,2050)),
|
||||
# widget=SelectDateWidget(years=range(1990,2050)),
|
||||
widget=AdminDateWidget(),
|
||||
label='Start Date')
|
||||
label='Start Date')
|
||||
enddate = forms.DateField(
|
||||
initial=timezone.now(),
|
||||
widget=AdminDateWidget(),
|
||||
label='End Date')
|
||||
label='End Date')
|
||||
|
||||
modechoices = (
|
||||
('rower','indoor rower'),
|
||||
@@ -533,7 +535,7 @@ class FitnessMetricForm(forms.Form):
|
||||
)
|
||||
|
||||
class Meta:
|
||||
fields = ['startdate','enddate','mode']
|
||||
fields = ['startdate','enddate','mode']
|
||||
|
||||
class SessionDateShiftForm(forms.Form):
|
||||
shiftstartdate = forms.DateField(
|
||||
@@ -599,7 +601,7 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
|
||||
|
||||
weightcategories = (
|
||||
('hwt','heavy-weight'),
|
||||
('lwt','light-weight'),
|
||||
('lwt','light-weight'),
|
||||
)
|
||||
|
||||
adaptivecategories = mytypes.adaptivetypes
|
||||
@@ -637,8 +639,8 @@ class RegistrationFormSex(RegistrationFormUniqueEmail):
|
||||
class MyTimeField(forms.TimeField):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MyTimeField, self).__init__(*args, **kwargs)
|
||||
supports_microseconds = True
|
||||
super(MyTimeField, self).__init__(*args, **kwargs)
|
||||
supports_microseconds = True
|
||||
|
||||
# Form used to automatically define intervals by pace or power
|
||||
class PowerIntervalUpdateForm(forms.Form):
|
||||
@@ -660,28 +662,28 @@ class PowerIntervalUpdateForm(forms.Form):
|
||||
class IntervalUpdateForm(forms.Form):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
typechoices = (
|
||||
(1,'single time'),
|
||||
(2,'single distance'),
|
||||
(3,'rest (time based)'),
|
||||
(3,'rest (distance based)'),
|
||||
(4,'work (time based)'),
|
||||
(5,'work (distance based)'),
|
||||
)
|
||||
aantal = int(kwargs.pop('aantal'))
|
||||
super(IntervalUpdateForm, self).__init__(*args, **kwargs)
|
||||
typechoices = (
|
||||
(1,'single time'),
|
||||
(2,'single distance'),
|
||||
(3,'rest (time based)'),
|
||||
(3,'rest (distance based)'),
|
||||
(4,'work (time based)'),
|
||||
(5,'work (distance based)'),
|
||||
)
|
||||
aantal = int(kwargs.pop('aantal'))
|
||||
super(IntervalUpdateForm, self).__init__(*args, **kwargs)
|
||||
|
||||
for i in range(aantal):
|
||||
self.fields['intervalt_%s' % i] = forms.DurationField(label='Time '+str(i+1))
|
||||
self.fields['intervald_%s' % i] = forms.IntegerField(label='Distance '+str(i+1))
|
||||
self.fields['type_%s' % i] = forms.ChoiceField(choices=typechoices,
|
||||
required=True,
|
||||
initial=4,
|
||||
label = 'Type '+str(i+1))
|
||||
self.fields['intervalt_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
|
||||
self.fields['intervald_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
|
||||
self.fields['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;'
|
||||
self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f')
|
||||
for i in range(aantal):
|
||||
self.fields['intervalt_%s' % i] = forms.DurationField(label='Time '+str(i+1))
|
||||
self.fields['intervald_%s' % i] = forms.IntegerField(label='Distance '+str(i+1))
|
||||
self.fields['type_%s' % i] = forms.ChoiceField(choices=typechoices,
|
||||
required=True,
|
||||
initial=4,
|
||||
label = 'Type '+str(i+1))
|
||||
self.fields['intervalt_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
|
||||
self.fields['intervald_%s' % i].widget.attrs['style'] = 'width:76px; height: 16px;'
|
||||
self.fields['type_%s' % i].widget.attrs['style'] = 'width:156px; height: 22px;'
|
||||
self.fields['intervald_%s' % i].widget = forms.TimeInput(format='%H:%M:%S.%f')
|
||||
|
||||
boattypes = mytypes.boattypes
|
||||
workouttypes = mytypes.workouttypes
|
||||
@@ -824,7 +826,7 @@ formaxlabelsmultiflex.pop('distance')
|
||||
formaxlabelsmultiflex['workoutid'] = 'Workout'
|
||||
parchoicesmultiflex = list(sorted(formaxlabelsmultiflex.items(), key = lambda x:x[1]))
|
||||
|
||||
from utils import palettes
|
||||
from rowers.utils import palettes
|
||||
|
||||
palettechoices = tuple((p,p) for p in palettes.keys())
|
||||
|
||||
@@ -950,7 +952,7 @@ class RaceResultFilterForm(forms.Form):
|
||||
|
||||
weightcategories = (
|
||||
('hwt','heavy-weight'),
|
||||
('lwt','light-weight'),
|
||||
('lwt','light-weight'),
|
||||
)
|
||||
|
||||
adaptivecategories = mytypes.adaptivetypes
|
||||
|
||||
Reference in New Issue
Block a user