• {% csrf_token %} - +

    New Team Session

    - {{ teamform.as_table }} + {{ teamform.as_table }}
    {{ form.as_table }}
    - +
  • {% if plannedsessions %} @@ -90,15 +90,18 @@ Clone - + Delete + + Save + {% endfor %} -

    +

    {% endif %}
  • @@ -150,7 +153,7 @@ $(document).ready(function(){ $("td #id_course").hide(); $("th label[for='id_course']").hide(); - + $("td #id_sessionmode").change(function() { if (this.value == 'TRIMP') { @@ -165,16 +168,16 @@ $("td #id_sessionunit").prop("value","min"); $('#id_guidance').html("

    Time: Set value to minutes

    "); } - + if (this.value == 'rScore') { $("td #id_sessionunit").prop("value","None"); $('#id_guidance').html("

    rScore has no unit

    "); } - + }); - + $("td #id_sessiontype").change(function() { - + if (this.value == 'session') { $("td #id_criterium").prop("value","none"); $('#id_guidance').html("

    For Training Sessions, the default criterium is 'Approximately'

    "); @@ -205,18 +208,18 @@ $("td #id_criterium").prop("value","minimum"); $('#id_guidance').html("

    For Challenges, the default criterium is 'At Least'

    "); } - + if (this.value == 'cycletarget') { $("td #id_criterium").prop("value","none"); $('#id_guidance').html("

    For Cycle Targets, the default criterium is 'Approximately'

    "); } - + } - + ); - + $("td #id_sessionunit").change(function() { - + if (this.value == 'm') { $("td #id_sessionmode").prop("value","distance"); $('#id_guidance').html("

    Mode was set to distance

    "); @@ -233,13 +236,13 @@ $("td #id_sessionmode").prop("value","time"); $('#id_guidance').html("

    Mode was set to time

    "); } - + } - - ); - - - + + ); + + + }); diff --git a/rowers/templates/plannedsessionteamedit.html b/rowers/templates/plannedsessionteamedit.html index 5bec388a..160a374e 100644 --- a/rowers/templates/plannedsessionteamedit.html +++ b/rowers/templates/plannedsessionteamedit.html @@ -19,10 +19,10 @@

  • -

    Back by +

    Back by {{ timeperiod|timedeltadays }} days

    -

    Forward by +

    Forward by {{ timeperiod|timedeltadays }} days

  • @@ -41,10 +41,10 @@

    Selecting a team assigns this session to all members of the team. Unselecting a team does not remove rowers - who are already assigned to this session. Use the Rowers selection for that. + who are already assigned to this session. Use the Rowers selection for that.

    - {{ teamform.as_table }} + {{ teamform.as_table }}

  • @@ -112,15 +112,18 @@ Clone - + Delete + + Save + {% endfor %} -

    +

    {% endif %}
  • @@ -134,7 +137,7 @@ $(document).ready(function(){ var o = $("td #id_sessiontype").find(":selected").val(); - + if (o != 'coursetest') { $("td #id_course").hide(); $("th label[for='id_course']").hide(); @@ -230,7 +233,7 @@ } - ); + ); diff --git a/rowers/templates/rower_form.html b/rowers/templates/rower_form.html index 23c1c456..3097ab60 100644 --- a/rowers/templates/rower_form.html +++ b/rowers/templates/rower_form.html @@ -19,6 +19,9 @@   {% endif %}

    +

    + Login {{ rower.user }} +

    {% if userform.errors %}

    Please correct the error{{ form.errors|pluralize }} below. @@ -26,7 +29,7 @@ {% endif %} {% if accountform.errors %}

    - +

    {% endif %}
    From b20381be9d8d4b28ed9af566df3dca152fd4ec14 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 16 Dec 2019 17:25:24 +0100 Subject: [PATCH 6/8] coaches can edit video analysis --- rowers/templates/embedded_video.html | 4 ++-- rowers/views/workoutviews.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rowers/templates/embedded_video.html b/rowers/templates/embedded_video.html index 789eb3c5..298577e6 100644 --- a/rowers/templates/embedded_video.html +++ b/rowers/templates/embedded_video.html @@ -306,7 +306,7 @@ function copyText() { } - {% if user.is_authenticated and user == workout.user.user %} + {% if user.is_authenticated and workout|may_edit:request %}
  • Lock Data and Video
  • @@ -322,7 +322,7 @@ function copyText() {
  • - {% if form and user.is_authenticated and user == workout.user.user %} + {% if form and user.is_authenticated and workout|may_edit:request %} {{ form.as_table }} diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index 6e7b8545..e113f19d 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -172,6 +172,9 @@ def workout_video_create_view(request,id=0): else: mode = 'erg' + + mayedit = checkworkoutuser(request.user,w) and isprorower(request.user.rower) + # get video ID and offset if request.method == 'POST': form = VideoAnalysisCreateForm(request.POST) From 724720aa39d87d5e09ca63d110d1af5ff17a8f85 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 17 Dec 2019 08:24:38 +0100 Subject: [PATCH 7/8] bug fix --- rowers/dataprep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rowers/dataprep.py b/rowers/dataprep.py index adfd720b..bbfd6ffb 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -1388,7 +1388,7 @@ def parsenonpainsled(fileformat,f2,summary): try: row = parsers[fileformat](f2) hasrecognized = True - except KeyError: + except (KeyError,IndexError): hasrecognized = False return None, hasrecognized, '', 'unknown' From 8109eee75fffc067402119dd80b2f14a3c4e9487 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 22 Dec 2019 20:13:30 +0100 Subject: [PATCH 8/8] fixing bugs in asynchronous tasks --- rowers/dataprepnodjango.py | 6 +++++- rowers/tasks.py | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rowers/dataprepnodjango.py b/rowers/dataprepnodjango.py index 52400767..f41498fb 100644 --- a/rowers/dataprepnodjango.py +++ b/rowers/dataprepnodjango.py @@ -715,6 +715,8 @@ def getsmallrowdata_db(columns,ids=[],debug=False): data = [] columns = [c for c in columns if c != 'None'] + df = pd.DataFrame() + if len(ids)>1: for id, f in zip(ids,csvfilenames): try: @@ -728,11 +730,13 @@ def getsmallrowdata_db(columns,ids=[],debug=False): df = pd.concat(data,axis=0) except ValueError: df = pd.DataFrame() - else: + elif len(ids)==1: try: df = pd.read_parquet(csvfilenames[0],columns=columns,engine='pyarrow') except (OSError,IndexError): df = pd.DataFrame() + else: + df = pd.DataFrame() return df diff --git a/rowers/tasks.py b/rowers/tasks.py index ab2c9261..e812a363 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -1754,15 +1754,15 @@ def handle_updatefitnessmetric(user_id,mode,workoutids,debug=False, def handle_updatecp(rower_id,workoutids,debug=False,table='cpdata',**kwargs): columns = ['power','workoutid','time'] df = getsmallrowdata_db(columns,ids=workoutids,debug=debug) - dfgrouped = df.groupby(['workoutid']) - if not df.empty: - maxt = 1.05*df['time'].max()/1000. - else: - maxt = 1000. + if df.empty: + return 0 + + maxt = 1.05*df['time'].max()/1000. logarr = datautils.getlogarr(maxt) + dfgrouped = df.groupby(['workoutid']) delta,cpvalue,avgpower = datautils.getcp(dfgrouped,logarr)