Private
Public Access
1
0

ready for merge back

This commit is contained in:
2024-12-14 13:58:23 +01:00
parent a7d48d711f
commit dfad4865c9
10 changed files with 61 additions and 67 deletions

View File

@@ -369,7 +369,7 @@ def workout_summary_to_df(
return df
def resample(id, r, parent, overwrite='copy'):
def resample(id, r, parent, overwrite=False):
data, row = getrowdata_db(id=id)
messages = []
@@ -393,7 +393,7 @@ def resample(id, r, parent, overwrite='copy'):
data['pace'] = data['pace'] / 1000.
data['time'] = data['time'] / 1000.
if overwrite == 'overwrite':
if overwrite == True:
# remove CP data
try:
cpfile = 'media/cpdata_{id}.parquet.gz'.format(id=parent.id)

View File

@@ -67,13 +67,12 @@ class FlexibleDecimalField(forms.DecimalField):
class ResampleForm(forms.Form):
resamplechoices = (
('overwrite', 'Overwrite Workout'),
('copy', 'Create a Duplicate Workout')
)
# add resamplechoice field, the result is a True or False boolean, labels are "overwrite" and "create copy"
resamplechoice = forms.ChoiceField(
initial='copy', choices=resamplechoices, label='Copy behavior')
required=True,
choices=((True, 'overwrite'), (False, 'create copy')),
label='Resample choice',
widget=forms.RadioSelect)
class TrainingZonesForm(forms.Form):
@@ -582,6 +581,11 @@ class UploadOptionsForm(forms.Form):
races = VirtualRace.objects.filter(
registration_closure__gt=timezone.now())
# set upload_to_X based on r.X_auto_export
for field in ['C2', 'Strava', 'SportTracks', 'TrainingPeaks', 'Intervals']:
if getattr(r, field.lower()+'_auto_export') and r.rowerplan in ['pro', 'plan','coach']:
self.fields['upload_to_'+field].initial = True
registrations = IndoorVirtualRaceResult.objects.filter(
race__in=races,
userid=r.id)
@@ -665,6 +669,10 @@ class TeamUploadOptionsForm(forms.Form):
upload_to_TrainingPeaks = forms.BooleanField(initial=False,
required=False,
label='Export to TrainingPeaks')
upload_to_Intervals = forms.BooleanField(initial=False,
required=False,
label='Export to TrainingPeaks')
# do_physics = forms.BooleanField(initial=False,required=False,label='Power Estimate (OTW)')
makeprivate = forms.BooleanField(initial=False, required=False,
label='Make Workout Private')

View File

@@ -17,6 +17,7 @@ import os
from uuid import uuid4
from django.utils import timezone
from datetime import timedelta
import rowers.dataprep as dataprep
from rowsandall_app.settings import (
INTERVALS_CLIENT_ID, INTERVALS_REDIRECT_URI, INTERVALS_CLIENT_SECRET, SITE_URL

View File

@@ -4561,6 +4561,7 @@ class RowerExportForm(ModelForm):
'rp3_auto_import',
'intervals_auto_import',
'intervals_auto_export',
'intervals_resample_to_1s'
]
class RowerExportFormStrava(ModelForm):
@@ -4616,7 +4617,6 @@ class RowerExportFormTrainingPeaks(ModelForm):
model = Rower
fields = [
'trainingpeaks_auto_export',
'rp3_auto_import',
]
class RowerExportFormRP3(ModelForm):

View File

@@ -64,13 +64,12 @@
</li>
{% endif %}
<li class="rounder">
<h2>Intervals.icu</h2>
<h2>NK</h2>
<table>
{{ forms.intervals.as_table }}
{{ forms.nk.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/intervalsauthorize"><img src="/static/img/intervals_icu.png"
alt="connect with intervals.icu"></a></p>
<p><a href="/rowers/me/nkauthorize/"><img src="/static/img/NKLiNKLogbook.png" alt="connect with NK Logbook" width="120"></a></p>
</li>
<li class="rounder">
<h2>Concept2</h2>
@@ -81,12 +80,27 @@
<p><a href="/rowers/me/c2authorize/"><img src="/static/img/blueC2logo.png" alt="connect with Concept2" width="120"></a></p>
</li>
<li class="rounder">
<h2>NK</h2>
<h2>RP3</h2>
<table>
{{ forms.nk.as_table }}
{{ forms.rp3.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/nkauthorize/"><img src="/static/img/NKLiNKLogbook.png" alt="connect with NK Logbook" width="120"></a></p>
<p><a href="/rowers/me/rp3authorize"><img src="/static/img/logo-rp3-full-black.png"
alt="connect with RP3" width="130"></a></p>
</li>
<li class="rounder">
<h2>Rojabo</h2>
<p><a href="/rowers/me/rojaboauthorize"><img src="/static/img/rojabo.png"
alt="connect with Rojabo" width="130"></a></p>
</li>
<li class="rounder">
<h2>Intervals.icu</h2>
<table>
{{ forms.intervals.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/intervalsauthorize"><img src="/static/img/intervals_logo_with_name.png"
alt="connect with intervals.icu"></a></p>
</li>
<li class="rounder">
<h2>SportTracks</h2>
@@ -102,6 +116,8 @@
{{ forms.trainingpeaks.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
alt="connect with Polar" width="130"></a></p>
</li>
<li class="rounder">
<h2>Polar</h2>
@@ -112,11 +128,6 @@
<p><a href="/rowers/me/polarauthorize/"><img src="/static/img/Polar_connectwith_btn_white.png"
alt="connect with Polar" width="130"></a></p>
</li>
<li class="rounder">
<h2>Rojabo</h2>
<p><a href="/rowers/me/rojaboauthorize"><img src="/static/img/rojabo.png"
alt="connect with Rojabo" width="130"></a></p>
</li>
<li class="rounder">
<h2>Garmin Connect</h2>
<table>
@@ -153,24 +164,6 @@
</p>
</li>
<li class="rounder">
<h2>TrainingPeaks</h2>
<table>
{{ forms.trainingpeaks.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
alt="connect with Polar" width="130"></a></p>
</li>
<li class="rounder">
<h2>RP3</h2>
<table>
{{ forms.rp3.as_table }}
<input type="submit" value="Save">
</table>
<p><a href="/rowers/me/rp3authorize"><img src="/static/img/logo-rp3-full-black.png"
alt="connect with RP3" width="130"></a></p>
</li>
{% if grants %}
<li class="rounder">
<h2>Applications</h2>

Binary file not shown.

View File

@@ -245,23 +245,6 @@ def do_sync(w, options, quick=False):
dologging('c2_log.log','Error C2')
pass
if do_strava_export: # pragma: no cover
strava_integration = StravaIntegration(w.user.user)
try:
id = strava_integration.workout_export(w)
dologging(
'strava_export_log.log',
'exporting workout {id} as {type}'.format(
id=w.id,
type=w.workouttype,
)
)
except NoTokenError: # pragma: no cover
id = 0
message = "Please connect to Strava first"
except Exception as e:
dologging('stravalog.log', e)
if do_icu_export:
intervals_integration = IntervalsIntegration(w.user.user)
try:
@@ -334,4 +317,23 @@ def do_sync(w, options, quick=False):
dologging('tp_export.log','No Token Error')
return 0
# we do Strava last.
if do_strava_export: # pragma: no cover
strava_integration = StravaIntegration(w.user.user)
try:
id = strava_integration.workout_export(w)
dologging(
'strava_export_log.log',
'exporting workout {id} as {type}'.format(
id=w.id,
type=w.workouttype,
)
)
except NoTokenError: # pragma: no cover
id = 0
message = "Please connect to Strava first"
except Exception as e:
dologging('stravalog.log', e)
return 1

View File

@@ -465,6 +465,7 @@ def rower_exportsettings_view(request, userid=0):
'rp3_auto_import': 'rp3token',
'nk_auto_import': 'nktoken',
'intervals_auto_export': 'intervals_token',
'intervals_resample_to_1s': 'intervals_token',
}
r = getrequestrowercoachee(request, userid=userid)

View File

@@ -5609,17 +5609,6 @@ def workout_upload_view(request,
return response
else:
if not is_ajax:
if r.c2_auto_export and ispromember(r.user): # pragma: no cover
uploadoptions['upload_to_C2'] = True
if r.strava_auto_export and ispromember(r.user): # pragma: no cover
uploadoptions['upload_to_Strava'] = True
if r.sporttracks_auto_export and ispromember(r.user): # pragma: no cover
uploadoptions['upload_to_SportTracks'] = True
if r.trainingpeaks_auto_export and ispromember(r.user): # pragma: no cover
uploadoptions['upload_to_TrainingPeaks'] = True
form = DocumentsForm(initial=docformoptions)
optionsform = UploadOptionsForm(initial=uploadoptions,