diff --git a/rowers/models.py b/rowers/models.py index f4715081..3ac826ff 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -4561,6 +4561,76 @@ class RowerExportForm(ModelForm): 'intervals_auto_import', 'intervals_auto_export', ] + +class RowerExportFormStrava(ModelForm): + class Meta: + model = Rower + fields = [ + 'stravaexportas', + 'strava_auto_export', + 'strava_auto_import', + 'strava_auto_delete', + ] + +class RowerExportFormIntervals(ModelForm): + class Meta: + model = Rower + fields = [ + 'intervals_auto_import', + 'intervals_auto_export', + ] + +class RowerExportFormGarmin(ModelForm): + class Meta: + model = Rower + fields = [ + 'garminactivity', + ] + +class RowerExportFormPolar(ModelForm): + class Meta: + model = Rower + fields = [ + 'polar_auto_import', + ] + +class RowerExportFormConcept2(ModelForm): + class Meta: + model = Rower + fields = [ + 'c2_auto_export', + 'c2_auto_import', + ] + +class RowerExportFormSportTracks(ModelForm): + class Meta: + model = Rower + fields = [ + 'sporttracks_auto_export', + ] + +class RowerExportFormTrainingPeaks(ModelForm): + class Meta: + model = Rower + fields = [ + 'trainingpeaks_auto_export', + 'rp3_auto_import', + ] + +class RowerExportFormRP3(ModelForm): + class Meta: + model = Rower + fields = [ + 'rp3_auto_import', + ] + +class RowerExportFormNK(ModelForm): + class Meta: + model = Rower + fields = [ + 'nk_auto_import' + ] + # Simple form to set rower's Functional Threshold Power class SimpleRowerPowerForm(ModelForm): diff --git a/rowers/templates/rower_exportsettings.html b/rowers/templates/rower_exportsettings.html index b6aae035..9625a472 100644 --- a/rowers/templates/rower_exportsettings.html +++ b/rowers/templates/rower_exportsettings.html @@ -7,8 +7,10 @@ {% block main %}

Import and Export Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}

+
+ {% csrf_token %}
    -
  • +
  • You are currently connected to: {% if rower.c2token is not None and rower.c2token != '' %} Concept2 Logbook, @@ -41,44 +43,140 @@ Intervals.icu {% endif %}

    - -{% if form.errors %} -

    - Please correct the error{{ form.errors|pluralize }} below. -

    -{% endif %} -

    - - - {{ form.as_table }} -
    - {% csrf_token %} - -

  • -

    -{% if rower.garmintoken and rower.garmintoken != '' %} -

    - You are connected to Garmin. Switching off Garmin Connect sync is on the - Account settings - page. Look for the "Rowsandall" app. -

    -{% endif %} -

    - Garmin Connnect has no manual sync, so connecting your account to your Garmin account will - automatically auto-sync workouts from Garmin to Rowsandall (but not in the other direction). If you - want to export our structured workout sessions to your Garmin device, you have to set the "Garmin Activity" - to a activity type that is supported by your watch. Not all watches support "Custom" activities, so - you may have to set your activity to Run or Ride while rowing. -

    -

    - Strava Auto Import also imports activity changes on Strava to Rowsandall, except when you delete - a workout on Strava. If you want Deletions to propagate to Rowsandall, tick the Strava Auto Delete - check box. -

    +

    + Click on the icons to establish the connection or to renew the authorization. +

    -
  • +
  • +

    API Key

    +

    {{ apikey }}

    +

    + Regenerate +

    +

    This API key can be used to access the Rowsandall API. It is used by some third party applications to access your data. Keep it secret.

    +
  • + + {% if form.errors %} +
  • +

    + Please correct the error{{ form.errors|pluralize }} below. +

    +
  • + {% endif %} +
  • +

    Polar

    + + {{ forms.polar.as_table }} + +
    +

    connect with Polar

    +
  • +
  • +

    Concept2

    + + {{ forms.c2.as_table }} + +
    +

    connect with Concept2

    +
  • +
  • +

    NK

    + + {{ forms.nk.as_table }} + +
    +

    connect with NK Logbook

    +
  • +
  • +

    SportTracks

    + + {{ forms.sporttracks.as_table }} + +
    +

    connect with SportTracks

    +
  • +
  • +

    TrainingPeaks

    + + {{ forms.trainingpeaks.as_table }} + +
    +
  • +
  • +

    Rojabo

    +

    connect with Rojabo

    +
  • +
  • +

    Intervals.icu

    + + {{ forms.intervals.as_table }} + +
    +

    connect with intervals.icu

    +
  • +
  • +

    Garmin Connect

    + + {{ forms.garmin.as_table }} + +
    +

    connect with Garmin

    + +

    + Garmin Connnect has no manual sync, so connecting your account to your Garmin account will + automatically auto-sync workouts from Garmin to Rowsandall (but not in the other direction). If you + want to export our structured workout sessions to your Garmin device, you have to set the "Garmin Activity" + to a activity type that is supported by your watch. Not all watches support "Custom" activities, so + you may have to set your activity to Run or Ride while rowing. +

    + {% if rower.garmintoken and rower.garmintoken != '' %} +

    + You are connected to Garmin. Switching off Garmin Connect sync is on the + Account settings + page. Look for the "Rowsandall" app. +

    + {% endif %} +
  • +
  • +

    Strava

    +

    + {{ forms.strava.as_p }} +

    connect with strava

    +

    + Strava Auto Import also imports activity changes on Strava to Rowsandall, except when you delete + a workout on Strava. If you want Deletions to propagate to Rowsandall, tick the Strava Auto Delete + check box. +

    + +
  • +
  • +

    TrainingPeaks

    + + {{ forms.trainingpeaks.as_table }} + +
    +

    connect with Polar

    +
  • +
  • +

    RP3

    + + {{ forms.rp3.as_table }} + +
    +

    connect with RP3

    +
  • {% if grants %} +
  • Applications

    +

    + These applications have access to your Rowsandall data. +

    @@ -99,35 +197,12 @@ {% endfor %}
    +
  • {% endif %} -

    API Key

    -

    {{ apikey }}

    -

    - Regenerate -

    - This API key can be used to access the Rowsandall API. It is used by some third party applications to access your data. Keep it secret. -
-

Click on one of the icons below to connect to the service of your - choice or to renew the authorization.

-

connect with strava

-

connect with Concept2

-

connect with NK Logbook

-

connect with SportTracks

-

connect with Polar

-

connect with Polar

- -

connect with Garmin

-

connect with RP3

-

connect with Rojabo

-

connect with intervals.icu

+ + {% endblock %} diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 01771ce6..09ac2fa1 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -179,7 +179,13 @@ from rowers.models import ( RowerPowerForm, RowerHRZonesForm, SimpleRowerPowerFo IndoorVirtualRaceForm, PlannedSessionCommentForm, Alert, Condition, StaticChartRowerForm, FollowerForm, VirtualRaceAthleteForm, InstantPlanForm, DataRowerForm, - StepEditorForm, iDokladToken ) + StepEditorForm, iDokladToken, + RowerExportFormStrava, RowerExportFormPolar, + RowerExportFormSportTracks, RowerExportFormTrainingPeaks, + RowerExportFormConcept2, RowerExportFormGarmin, + RowerExportFormIntervals, RowerExportFormRP3, + RowerExportFormNK, + ) from rowers.models import ( FavoriteForm, BaseFavoriteFormSet, SiteAnnouncement, BasePlannedSessionFormSet, get_course_timezone, BaseConditionFormSet, diff --git a/rowers/views/userviews.py b/rowers/views/userviews.py index ddd4fe73..d2d22e25 100644 --- a/rowers/views/userviews.py +++ b/rowers/views/userviews.py @@ -457,19 +457,42 @@ def rower_exportsettings_view(request, userid=0): 'polar_auto_import': 'polartoken', 'c2_auto_export': 'c2token', 'c2_auto_import': 'c2token', - 'runkeeper_auto_export': 'runkeepertoken', 'sporttracks_auto_export': 'sporttrackstoken', 'strava_auto_export': 'stravatoken', 'strava_auto_import': 'stravatoken', 'strava_auto_delete': 'stravatoken', 'trainingpeaks_auto_export': 'tptoken', 'rp3_auto_import': 'rp3token', - 'nk_auto_import': 'nktoken' + 'nk_auto_import': 'nktoken', + 'intervals_auto_export': 'intervals_token', } r = getrequestrowercoachee(request, userid=userid) + + forms = { + 'polar': RowerExportFormPolar(instance=r), + 'c2': RowerExportFormConcept2(instance=r), + 'sporttracks': RowerExportFormSportTracks(instance=r), + 'strava': RowerExportFormStrava(instance=r), + 'trainingpeaks': RowerExportFormTrainingPeaks(instance=r), + 'rp3': RowerExportFormRP3(instance=r), + 'intervals': RowerExportFormIntervals(instance=r), + 'nk': RowerExportFormNK(instance=r), + 'garmin': RowerExportFormGarmin(instance=r), + } if request.method == 'POST': form = RowerExportForm(request.POST) + forms = { + 'polar': RowerExportFormPolar(request.POST, instance=r), + 'c2': RowerExportFormConcept2(request.POST, instance=r), + 'sporttracks': RowerExportFormSportTracks(request.POST, instance=r), + 'strava': RowerExportFormStrava(request.POST, instance=r), + 'trainingpeaks': RowerExportFormTrainingPeaks(request.POST, instance=r), + 'rp3': RowerExportFormRP3(request.POST, instance=r), + 'intervals': RowerExportFormIntervals(request.POST, instance=r), + 'nk': RowerExportFormNK(request.POST, instance=r), + 'garmin': RowerExportFormGarmin(request.POST, instance=r), + } if form.is_valid(): cd = form.cleaned_data if r.rowerplan == 'basic': # pragma: no cover @@ -528,6 +551,7 @@ def rower_exportsettings_view(request, userid=0): return render(request, 'rower_exportsettings.html', {'form': form, + 'forms': forms, 'rower': r, 'breadcrumbs': breadcrumbs, 'grants': grants,