diff --git a/rowers/templates/workout_courses.html b/rowers/templates/workout_courses.html index 1a177d37..1d0d46f0 100644 --- a/rowers/templates/workout_courses.html +++ b/rowers/templates/workout_courses.html @@ -9,7 +9,7 @@ {% endblock %} {% block scripts %} - +{% include "monitorjobs.html" %} {% endblock %} {% block title %}{{ workout.name }} {% endblock %} @@ -25,7 +25,6 @@
+ This functionality allows you to record a time on a set course that you've rowed during the workout. + The summary will be updated to show time on course, and you can compare this with other + attempts. +
++ {% if rower.share_course_results %} + You are currently sharing your course results with all Rowsandall users. + Click here to hide your course results. + {% else %} + You are currently hiding your course results (except for your participation in online challenges). + Click here to hide your course results. + {% endif %} +
+ +| Rower: | {{ first_name }} {{ last_name }} | diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 367e5b6f..d386d6a9 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -765,6 +765,7 @@ verbose_job_status = { 'long_test_task2': 'Long Test Task 2', 'update_empower': 'Correct Empower Inflated Power Bug', 'submit_race': 'Checking Race Course Result', + 'check_race_course': 'Checking Course Result', } def get_job_status(jobid): # pragma: no cover diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 66a982cf..f88f8938 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -6088,13 +6088,63 @@ def workout_course_view(request, id): strict=True) courseselectform = CourseSelectForm(choices=courses) + + + if request.method == 'POST': + courseselectform = CourseSelectForm(request.POST,choices=courses) + if courseselectform.is_valid(): + course = courseselectform.cleaned_data['course'] + # get or create a record + records = VirtualRaceResult.objects.filter( + userid=r.id, + course=course, + workoutid=row.id + ) + if records: + record = records[0] + else: + # create record + record = VirtualRaceResult( + userid = r.id, + username = r.user.first_name+' '+r.user.last_name, + workoutid = row.id, + weightcategory = r.weightcategory, + adaptiveclass = r.adaptiveclass, + course = course, + distance = course.distance, + boatclass = row.workouttype, + boattype = row.boattype, + sex = r.sex, + age = calculate_age(r.birthdate), + ) + record.save() + + job = myqueue( + queuehigh, + handle_check_race_course, + row.csvfilename, + row.id, + course.id, + record.id, + r.user.email, + r.user.first_name, + summary=True, + successemail=True, + ) + + try: + request.session['async_tasks'] += [(job.id,'check_race_course')] + except KeyError: + request.session['async_tasks'] = [(job.id,'check_race_course')] + + messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status here') + # get results records = VirtualRaceResult.objects.filter( course__isnull=False, workoutid=row.id, coursecompleted=True).order_by("duration","-distance") - return render(request, 'workout_courses.html', {'workout':row, 'rower':r, @@ -6277,7 +6327,13 @@ def workout_summary_edit_view(request,id,message="",successmessage="" summary=True, successemail=True, ) - messages.info(request,'We are checking your time on the course in the background') + + try: + request.session['async_tasks'] += [(job.id,'check_race_course')] + except KeyError: + request.session['async_tasks'] = [(job.id,'check_race_course')] + + messages.info(request,'We are checking your time on the course in the background. You will receive an email when the check is complete. You can check the status here') vals = None # feeling lucky / ruptures
|---|