From cf661f4ae5883117bea68f1662b95291bb5e734d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 16 Dec 2018 12:28:43 +0100 Subject: [PATCH 1/4] cosmetic changes in race view --- rowers/templates/virtualevent.html | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 71f905c2..cd71ec5d 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -266,7 +266,13 @@ {{ result.age }} {{ result.sex }} {{ result.weightcategory }} - {{ result.adaptiveclass }} + + {% if result.adaptiveclass == 'None' %} +   + {% else %} + {{ result.adaptiveclass }} + {% endif %} + {% if race.sessiontype == 'race' %} {{ result.boatclass }} {{ result.boattype }} @@ -295,7 +301,13 @@ {{ result.age }} {{ result.sex }} {{ result.weightcategory }} - {{ result.adaptiveclass }} + + {% if result.adaptiveclass == 'None' %} +   + {% else %} + {{ result.adaptiveclass }} + {% endif %} + {% if race.sessiontype == 'race' %} {{ result.boatclass }} {{ result.boattype }} @@ -363,7 +375,13 @@ {{ record.age }} {{ record.sex }} {{ record.weightcategory }} - {{ record.adaptiveclass }} + + {% if record.adaptiveclass == 'None' %} +   + {% else %} + {{ record.adaptiveclass }} + {% endif %} + {% if record.userid == rower.id and 'withdrawbutton' in buttons %} Withdraw From 4d89711b582aff579dd326c175bbda74108d114d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 17 Dec 2018 09:46:23 +0100 Subject: [PATCH 2/4] improved race filtering --- rowers/forms.py | 6 +++--- rowers/templates/summary_edit.html | 2 +- rowers/templates/virtualevent.html | 10 ++++------ rowers/templates/workout_form.html | 2 +- rowers/views.py | 13 ------------- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/rowers/forms.py b/rowers/forms.py index 3d7a7070..fc4de42a 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -880,8 +880,8 @@ class WorkoutSessionSelectForm(forms.Form): class RaceResultFilterForm(forms.Form): - boatclasses = (type for type in mytypes.workouttypes if type[0] in mytypes.otwtypes) - boatclassinitial = [t for t in mytypes.otwtypes] + boatclasses = (type for type in mytypes.workouttypes if type[0] in mytypes.rowtypes) + boatclassinitial = [t for t in mytypes.rowtypes] sexchoices = ( ('female','Female'), ('male','Male'), @@ -904,7 +904,7 @@ class RaceResultFilterForm(forms.Form): boatclass = forms.MultipleChoiceField( choices=boatclasses, initial=boatclassinitial, - label='Boat Class', + label='Boat/Erg Class', widget=forms.CheckboxSelectMultiple()) boattype = forms.MultipleChoiceField( diff --git a/rowers/templates/summary_edit.html b/rowers/templates/summary_edit.html index f0bc4592..5d61d6bf 100644 --- a/rowers/templates/summary_edit.html +++ b/rowers/templates/summary_edit.html @@ -100,7 +100,7 @@
  • Detailed Summary Edit

    -

    This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save on the summary above. You can use the restore original button to restore the original values.

    +

    This is still experimental and there are known bugs. Use at your own risk. Nothing is stored permanently until you hit Save in the Updated Summary section. You can use the restore original button to restore the original values.

    diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index cd71ec5d..55756c53 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -245,8 +245,8 @@ - {% if race.sessiontype == 'race' %} + {% if race.sessiontype == 'race' %} {% endif %} @@ -273,8 +273,8 @@ {{ result.adaptiveclass }} {% endif %} - {% if race.sessiontype == 'race' %} + {% if race.sessiontype == 'race' %} {% endif %} @@ -308,8 +308,8 @@ {{ result.adaptiveclass }} {% endif %} - {% if race.sessiontype == 'race' %} + {% if race.sessiontype == 'race' %} {% endif %} @@ -366,11 +366,9 @@ + {% if race.sessiontype == 'race' %} - - {% else %} - {% endif %} diff --git a/rowers/templates/workout_form.html b/rowers/templates/workout_form.html index d2fd7321..59136d08 100644 --- a/rowers/templates/workout_form.html +++ b/rowers/templates/workout_form.html @@ -119,7 +119,7 @@ $('#id_workouttype').change();

    {% if indoorraces %} -
  • +
  • Racing

    {% for race in indoorraces %}

    diff --git a/rowers/views.py b/rowers/views.py index c7b4d897..609192f0 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -17595,14 +17595,6 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0): selectedworkout = w_form.cleaned_data['workouts'] splitsecond = 0 recordid = w_form.cleaned_data['record'] -# splittime = w_form.cleaned_data['evaluate_after'] -# if splittime is not None: -# splitsecond = splittime.hour*3600 -# splitsecond += splittime.minute*60 -# splitsecond += splittime.second -# splitsecond += splittime.microsecond/1.e6 -# else: -# splitsecond = 0 else: selectedworkout = None @@ -17621,11 +17613,6 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0): workouts,race,r,recordid=recordid) - # if result: -# for w in ws: -# remove_workout_plannedsession(w,race) -# delete_race_result(w,race) - for c in comments: messages.info(request,c) for er in errors: From 5b6a376c58b59edaf4724c0220f0db0c8617f5e0 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 17 Dec 2018 10:48:15 +0100 Subject: [PATCH 3/4] race comparison --- rowers/templates/menu_racing.html | 6 ++ rowers/templates/multicompare.html | 4 + rowers/urls.py | 1 + rowers/views.py | 133 +++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) diff --git a/rowers/templates/menu_racing.html b/rowers/templates/menu_racing.html index 305818c4..e377f57f 100644 --- a/rowers/templates/menu_racing.html +++ b/rowers/templates/menu_racing.html @@ -16,6 +16,12 @@

  • {% if race %} + {% if results %} +
  • + +  Compare Results +
  • + {% endif %} {% if reguest.user.is_anonymous %}
  • {% if race.sessiontype == 'race' %} diff --git a/rowers/templates/multicompare.html b/rowers/templates/multicompare.html index 3096a343..78d59f2c 100644 --- a/rowers/templates/multicompare.html +++ b/rowers/templates/multicompare.html @@ -41,5 +41,9 @@ {% endblock %} {% block sidebar %} +{% if active == 'nav-racing' %} +{% include 'menu_racing.html' %} +{% else %} {% include 'menu_workouts.html' %} +{% endif %} {% endblock %} diff --git a/rowers/urls.py b/rowers/urls.py index 242c07b4..c64090b0 100644 --- a/rowers/urls.py +++ b/rowers/urls.py @@ -278,6 +278,7 @@ urlpatterns = [ url(r'^workout/(?P\d+)/interactiveotwplot$',views.workout_otwpowerplot_view), url(r'^workout/(?P\d+)/wind$',views.workout_wind_view), url(r'^workout/(?P\d+)/image$',views.workout_uploadimage_view), + url(r'^virtualevent/(?P\d+)/compare$',views.virtualevent_compare_view), url(r'^virtualevent/(?P\d+)/image$', views.virtualevent_uploadimage_view), url(r'^virtualevent/(?P\d+)/setimage/(?P\d+)/$', diff --git a/rowers/views.py b/rowers/views.py index 609192f0..c4a69681 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -5598,6 +5598,139 @@ def team_comparison_select(request, 'teams':get_my_teams(request.user), }) +def virtualevent_compare_view(request,id=0): + results = [] + + promember = 0 + if not request.user.is_anonymous(): + r = getrower(request.user) + result = request.user.is_authenticated() and ispromember(request.user) + if result: + promember=1 + else: + r = None + + try: + race = VirtualRace.objects.get(id=id) + except VirtualRace.DoesNotExist: + raise Http404("Virtual Race does not exist") + + if race.sessiontype == 'race': + script,div = course_map(race.course) + resultobj = VirtualRaceResult + else: + script = '' + div = '' + resultobj = IndoorVirtualRaceResult + + results = resultobj.objects.filter( + race=race, + workoutid__isnull=False, + coursecompleted=True, + ).order_by("duration","-distance") + + workoutids = [result.workoutid for result in results] + + if request.method == 'GET': + xparam = race.sessionmode if race.sessionmode in ['distance','time'] else 'time' + yparam = 'pace' + plottype = 'line' + + + + request.session['ids'] = workoutids + request.session['plottype'] = plottype + request.session['xparam'] = xparam + request.session['yparam'] = yparam + + + workouts = [] + for id in workoutids: + try: + workouts.append(Workout.objects.get(id=id)) + except Workout.DoesNotExist: + pass + + labeldict = { + int(w.id): w.__unicode__() for w in workouts + } + + chartform = ChartParamChoiceForm( + initial = { + 'xparam':xparam, + 'yparam':yparam, + 'plottype':plottype, + 'teamid':0 + } + ) + elif request.method == 'POST': + chartform = ChartParamChoiceForm(request.POST) + if chartform.is_valid(): + xparam = chartform.cleaned_data['xparam'] + yparam = chartform.cleaned_data['yparam'] + plottype = chartform.cleaned_data['plottype'] + teamid = chartform.cleaned_data['teamid'] + workoutids = request.session['ids'] + request.session['ids'] = workoutids + workouts = [] + for id in workoutids: + try: + workouts.append(Workout.objects.get(id=id)) + except Workout.DoesNotExist: + pass + + labeldict = { + int(w.id): w.__unicode__() for w in workouts + } + res = interactive_multiple_compare_chart(workoutids,xparam,yparam, + promember=promember, + plottype=plottype, + labeldict=labeldict) + script = res[0] + div = res[1] + errormessage = res[3] + if errormessage != '': + messages.error(request,errormessage) + + breadcrumbs = [ + { + 'url': reverse(virtualevents_view), + 'name': 'Racing' + }, + { + 'url':reverse(virtualevent_view, + kwargs={ + 'id':race.id, + } + ), + 'name': race.name + }, + { + 'url':reverse(virtualevent_compare_view, + kwargs={ + 'id':race.id, + } + ), + 'name': 'Compare' + } + ] + + + return render(request,'multicompare.html', + {'interactiveplot':script, + 'the_div':div, + 'breadcrumbs':breadcrumbs, + 'rower':r, + 'race':race, + 'results':results, + 'active':'nav-racing', + 'promember':promember, + 'teamid':0, + 'chartform':chartform, + 'teams':[] + }) + + @login_required() def plannedsession_compare_view(request,id=0,userid=0): r = getrequestrower(request,userid=userid) From afca50278e024ffd3a2af173a3af4c3674cfa32d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 17 Dec 2018 10:54:56 +0100 Subject: [PATCH 4/4] race comparison --- rowers/templates/virtualevent.html | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rowers/templates/virtualevent.html b/rowers/templates/virtualevent.html index 55756c53..9711bb3c 100644 --- a/rowers/templates/virtualevent.html +++ b/rowers/templates/virtualevent.html @@ -233,8 +233,8 @@

    Results

    {% endif %}

    + {% if results or dns %}

    - {% if results or dns %}

  •      ClassBoatTime{{ result.boatclass }}{{ result.boattype }}{{ result.duration |durationprint:"%H:%M:%S.%f" }}{{ result.boatclass }}{{ result.boattype }}DNS
    {{ record.username }} {{ record.teamname }}{{ record.boatclass }}{{ record.boatclass }} {{ record.boattype }}{{ record.boatclass }}{{ record.age }} {{ record.sex }}
    @@ -317,10 +317,16 @@ {% endfor %}
    - {% else %} - No results yet - {% endif %}

    +

    + Compare Results +

    + {% else %} +

    + No results yet +

    + {% endif %}
  • {% if form %}