diff --git a/rowers/models.py b/rowers/models.py index 0d06135a..59c3d94a 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2000,9 +2000,20 @@ class IndoorVirtualRaceForm(ModelForm): 'evaluation_closure':AdminSplitDateTime(), } + labels = { + 'sessionunit': 'Meters or minutes', + 'sessionvalue': 'How far or how long' + } + + def __init__(self,*args,**kwargs): + timezone = kwargs.pop('timezone',None) super(IndoorVirtualRaceForm, self).__init__(*args, **kwargs) self.fields['sessionunit'].choices = [('min','minutes'),('m','meters')] + self.fields['sessionvalue'].initial = 2000 + self.fields['sessionunit'].initial = 'm' + if timezone: + self.fields['timezone'].initial = timezone def clean(self): cd = self.cleaned_data diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 93fd2322..4a1da8e4 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -61,6 +61,7 @@ def get_indoorraces(workout): registrations = IndoorVirtualRaceResult.objects.filter( race__in = races, + boatclass = workout.workouttype, userid=workout.user.id) races = [r.race for r in registrations] @@ -1008,7 +1009,10 @@ def add_workout_indoorrace(ws,race,r,recordid=0): record.distance = ws[0].distance record.duration = ws[0].duration - + if ws[0].workouttype != record.boatclass: + errors.append('Your workout boat class is different than on your race registration') + return 0,comments,errors,0 + if ws[0].workouttype not in mytypes.otetypes: errors.append('You must submit a indoor rowing workout') return 0,comments, errors, 0 @@ -1109,6 +1113,9 @@ def add_workout_race(ws,race,r,splitsecond=0,recordid=0): errors.append('You have to submit a rowing on water workout') return 0,comments,errors,0 + if ws[0].workouttype != record.boatclass: + errors.append('Your workout boat class is different than on your race registration') + return 0,comments,errors,0 if ws[0].boattype != record.boattype: errors.append('Your workout boat type did not match the boat type you registered') diff --git a/rowers/templates/plannedsessions.html b/rowers/templates/plannedsessions.html index e50c938e..e59befdd 100644 --- a/rowers/templates/plannedsessions.html +++ b/rowers/templates/plannedsessions.html @@ -9,7 +9,7 @@