From 105a78d392b46c2537b24169b796f8cc01de2aa8 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
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.
- -This is a quick way to enter the intervals using a special mini-language.
You enter something like 8x500m/3min, press "Update" and the site will interpret this for you and update the summary on the right. If you're happy with the result, press the green Save button to update the values. Nothing will be changed permanently until you hit Save.
diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 1227ff68..1f46d518 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -6425,133 +6425,9 @@ def workout_summary_edit_view(request,id,message="",successmessage="" } powerupdateform = PowerIntervalUpdateForm(initial=cd) form = SummaryStringForm(initial={'intervalstring':intervalString}) - - - - # we are saving the results obtained from the detailed form - elif request.method == 'POST' and "savedetailform" in request.POST: # pragma: no cover - savebutton = 'savedetailform' - form = SummaryStringForm() - nrintervals = int(request.POST['nrintervals']) - detailform = IntervalUpdateForm(request.POST,aantal=nrintervals) - itime = [] - idist = [] - itype = [] - ivalues = [] - iunits = [] - itypes = [] - iresults = [] - for i in range(nrintervals): - try: - t = datetime.datetime.strptime(request.POST['intervalt_%s' % i],"%H:%M:%S.%f") - except ValueError: - t = datetime.datetime.strptime(request.POST['intervalt_%s' % i],"%H:%M:%S") - - timesecs = 3600*t.hour+60*t.minute+t.second+t.microsecond/1.e6 - itime += [timesecs] - idist += [int(request.POST['intervald_%s' % i])] - itype += [int(request.POST['type_%s' % i])] - - if itype[i] == 3: # rest - itypes += ['rest'] - ivalues += [timesecs] - iresults += [idist[i]] - iunits += ['seconds'] - if itype[i] == 5 or itype[i] == 2: # distance based work - itypes += ['work'] - ivalues += [idist[i]] - iresults += [timesecs] - iunits += ['meters'] - if itype[i] == 4 or itype[i] == 1: # time based work - itypes += ['work'] - ivalues += [timesecs] - iresults += [idist[i]] - iunits += ['seconds'] - - - rowdata.updateintervaldata(ivalues,iunits,itypes,iresults=iresults) - intervalstats = rowdata.allstats() - row.summary = intervalstats - try: - row.notes += "\n"+s - except TypeError: - pass - - row.save() - rowdata.write_csv(f1,gzip=True) - dataprep.update_strokedata(encoder.decode_hex(id),rowdata.df) - messages.info(request,"Updated interval data saved") - - form = SummaryStringForm() - powerupdateform = PowerIntervalUpdateForm(initial={ - 'power': int(normp), - 'pace': avpace, - 'selector': 'power', - 'work': int(normw), - 'spm': int(normspm), - 'activeminutesmin': 0, - 'activeminutesmax': activeminutesmax, - }) - - - # we are processing the details form - elif request.method == 'POST' and "nrintervals" in request.POST: # pragma: no cover - savebutton = 'savedetailform' - nrintervals = int(request.POST['nrintervals']) - detailform = IntervalUpdateForm(request.POST,aantal=nrintervals) - if detailform.is_valid(): - cd = detailform.cleaned_data - itime = [] - idist = [] - itype = [] - ivalues = [] - iunits = [] - itypes = [] - iresults = [] - for i in range(nrintervals): - t = cd['intervalt_%s' % i] - timesecs = t.total_seconds() - itime += [timesecs] - idist += [cd['intervald_%s' % i]] - itype += [cd['type_%s' % i]] - - if itype[i] == '3': # rest - itypes += ['rest'] - ivalues += [timesecs] - iresults += [idist[i]] - iunits += ['seconds'] - if itype[i] == '5' or itype[i] == '2': # distance based work - itypes += ['work'] - ivalues += [idist[i]] - iresults += [timesecs] - iunits += ['meters'] - if itype[i] == '4' or itype[i] == '1': # time based work - itypes += ['work'] - ivalues += [timesecs] - iresults += [idist[i]] - iunits += ['seconds'] - - rowdata.updateintervaldata(ivalues,iunits, - itypes,iresults=iresults) - intervalstats = rowdata.allstats() - - - form = SummaryStringForm() - powerupdateform = PowerIntervalUpdateForm() - initial = {} - for i in range(nrintervals): - try: - initial['intervald_%s' % i] = idist[i] - initial['intervalt_%s' % i] = get_time(itime[i]) - initial['type_%s' % i] = itype[i] - except IndexError: # pragma: no cover - pass - - - detailform = IntervalUpdateForm(aantal=nrintervals,initial=initial) # create interactive plot try: @@ -6576,7 +6452,6 @@ def workout_summary_edit_view(request,id,message="",successmessage="" 'activeminutesmax':activeminutesmax, 'activeminutesmin':activeminutesmin, 'maxminutes': maxminutes, - 'detailform':detailform, 'powerupdateform':powerupdateform, 'workout':row, 'rower':r,