diff --git a/rowers/models.py b/rowers/models.py index ce91d5c2..09a61c8b 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2690,7 +2690,7 @@ class WorkoutForm(ModelForm): startdate__lte=workout.date, enddate__gte=workout.date, ).order_by("preferreddate","startdate","enddate").exclude( - sessiontype='race') + sessiontype__in=['race','indoorrace']) if not sps: del self.fields['plannedsession'] diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index fdef9f08..09c657b4 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -20,7 +20,7 @@ from rowers.models import ( Rower, Workout,Team, GeoCourse, TrainingMicroCycle,TrainingMesoCycle,TrainingMacroCycle, TrainingPlan,PlannedSession,VirtualRaceResult,CourseTestResult, - get_course_timezone, IndoorVirtualRaceResult + get_course_timezone, IndoorVirtualRaceResult,VirtualRace ) from rowers.courses import get_time_course @@ -33,6 +33,41 @@ import iso8601 from iso8601 import ParseError from rowers.tasks import handle_check_race_course +def get_indoorraces(workout): + races1 = VirtualRace.objects.filter( + registration_closure__gt=timezone.now(), + sessiontype='indoorrace', + startdate__lte=workout.date, + enddate__gte=workout.date, + sessionmode='distance', + sessionvalue=workout.distance) + + + if workout.duration.second != 0 and workout.duration.microsecond != 0: + duration = 60*workout.duration.hour+workout.duration.minute + + + races2 = VirtualRace.objects.filter( + registration_closure__gt=timezone.now(), + sessiontype='indoorrace', + startdate__lte=workout.date, + enddate__gte=workout.date, + sessionmode='time', + sessionvalue=duration) + + races = races1 | races2 + else: + races = races1 + + registrations = IndoorVirtualRaceResult.objects.filter( + race__in = races, + userid=workout.user.id) + + races = [r.race for r in registrations] + + + return races + def get_todays_micro(plan,thedate=date.today()): thismicro = None diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 7271460e..cf192349 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -155,7 +155,37 @@ data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{
{% endif %} {% if button == 'submitbutton' %} - Submit Result +| + Submit Workout + | ++ Submit a workout that is already on the site as your race result + | +
| + Upload your race result + | ++ Upload a new workout to the site and submit it as a result. You + need a workout data file. + | +
| + Enter your race result manually + | ++ If you don't have a data file, enter the results + manually. If you have a photo of the monitor with the + result, it is recommended to add this to the workout. + | +
diff --git a/rowers/templates/workout_form.html b/rowers/templates/workout_form.html index ce0e29e6..986878ec 100644 --- a/rowers/templates/workout_form.html +++ b/rowers/templates/workout_form.html @@ -118,6 +118,16 @@ $('#id_workouttype').change();
+ {% if indoorraces %} +