diff --git a/rowers/polarstuff.py b/rowers/polarstuff.py index 60aad0d8..9b9c0e9e 100644 --- a/rowers/polarstuff.py +++ b/rowers/polarstuff.py @@ -145,6 +145,8 @@ def get_polar_notifications(): return available_data +from rowers.utils import isprorower + def get_all_new_workouts(available_data,testing=False): for record in available_data: if testing: @@ -153,7 +155,7 @@ def get_all_new_workouts(available_data,testing=False): try: r = Rower.objects.get(polaruserid=record['user-id']) u = r.user - if r.polar_auto_import: + if r.polar_auto_import and isprorower(r): exercise_list = get_polar_workouts(u) if testing: print exercise_list diff --git a/rowers/templates/imports.html b/rowers/templates/imports.html index 857802a2..87dbd002 100644 --- a/rowers/templates/imports.html +++ b/rowers/templates/imports.html @@ -103,6 +103,7 @@

Auto Import/Export Settings

+

Use the form below to set your auto import/export settings. As we implement auto import/export for various partner sites, this form will be expanded.

@@ -112,6 +113,9 @@

Auto Export = New workouts uploaded to rowsandall.com will be automatically synchronized to the partner site

+ +

These settings only have effect if you are a user on one + of the paid plans

@@ -124,6 +128,7 @@
+ diff --git a/rowers/templates/promembership.html b/rowers/templates/promembership.html index f1094c22..c3422175 100644 --- a/rowers/templates/promembership.html +++ b/rowers/templates/promembership.html @@ -39,12 +39,19 @@ ✔ - Import, Export, Synchronization and download of all your data + Manual Import, Export, Synchronization and download of all your data ✔ ✔ ✔ ✔ + + Automatic Synchronization with other fitness sites +   + ✔ + ✔ + ✔ + Heart rate and power zones ✔ diff --git a/rowers/uploads.py b/rowers/uploads.py index c5cc9619..07b5cdce 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -373,15 +373,17 @@ def make_private(w,options): return 1 +from rowers.utils import isprorower + def do_sync(w,options): - if ('upload_to_C2' in options and options['upload_to_C2']) or w.user.c2_auto_export: + if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and isprorower(w.user)): try: message,id = c2stuff.workout_c2_upload(w.user.user,w) except c2stuff.C2NoTokenError: id = 0 message = "Something went wrong with the Concept2 sync" - if ('upload_to_Strava' in options and options['upload_to_Strava']) or w.user.strava_auto_export: + if ('upload_to_Strava' in options and options['upload_to_Strava']) or (w.user.strava_auto_export and isprorower(w.user)): try: message,id = stravastuff.workout_strava_upload( w.user.user,w @@ -391,7 +393,7 @@ def do_sync(w,options): message = "Please connect to Strava first" - if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or w.user.sporttracks_auto_export: + if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or (w.user.sporttracks_auto_export and isprorower(w.user)): try: message,id = sporttracksstuff.workout_sporttracks_upload( w.user.user,w @@ -401,7 +403,7 @@ def do_sync(w,options): id = 0 - if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or w.user.runkeeper_auto_export: + if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or (w.user.runkeeper_auto_export and isprorower(w.user)): try: message,id = runkeeperstuff.workout_runkeeper_upload( w.user.user,w @@ -410,7 +412,7 @@ def do_sync(w,options): message = "Please connect to Runkeeper first" id = 0 - if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or w.user.mapmyfitness_auto_export: + if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or (w.user.mapmyfitness_auto_export and isprorower(w.user)): try: message,id = underarmourstuff.workout_ua_upload( w.user.user,w @@ -420,7 +422,7 @@ def do_sync(w,options): id = 0 - if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or w.user.trainingpeaks_auto_export: + if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or (w.user.trainingpeaks_auto_export and isprorower(w.user)): try: message,id = tpstuff.workout_tp_upload( w.user.user,w diff --git a/rowers/utils.py b/rowers/utils.py index d9c7ec54..635d255a 100644 --- a/rowers/utils.py +++ b/rowers/utils.py @@ -369,3 +369,12 @@ def totaltime_sec_to_string(totaltime): duration = "%s:%s:%s.%s" % (hours, minutes, seconds, tenths) return duration + +def isprorower(r): + result = False + result = r.rowerplan in ['pro','coach','plan'] + if not result and r.protrialexpires: + result = r.rowerplan is 'basic' and r.protrialexpires >= datetime.date.today() + + return result + diff --git a/rowers/views.py b/rowers/views.py index 7d0cf662..0f36576f 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -926,6 +926,8 @@ def hasplannedsessions(user): return result +from rowers.utils import isprorower + # Check if a user is a Pro member def ispromember(user): if not user.is_anonymous(): @@ -934,10 +936,8 @@ def ispromember(user): except Rower.DoesNotExists: r = Rower(user=user) r.save() - - result = user.is_authenticated() and (r.rowerplan=='pro' or r.rowerplan=='coach' or r.rowerplan=='plan') - if not result and r.protrialexpires: - result = user.is_authenticated() and r.rowerplan=='basic' and r.protrialexpires >= datetime.date.today() + + result = user.is_authenticated() and isprorower(r) else: result = False return result @@ -2684,9 +2684,6 @@ def imports_view(request): r.save() - # polar_auto_import = cd['polar_auto_import'] - # r.polar_auto_import = polar_auto_import - # r.save() else: form = RowerImportExportForm(instance=r) @@ -10516,7 +10513,7 @@ def workout_upload_view(request, request.session['async_tasks'] = [(jobid,'make_plot')] # upload to C2 - if (upload_to_c2) or (w.user.c2_auto_export): + if (upload_to_c2) or (w.user.c2_auto_export and isprorower(w.user)): try: message,id = c2stuff.workout_c2_upload(request.user,w) except C2NoTokenError: @@ -10527,7 +10524,7 @@ def workout_upload_view(request, else: messages.error(request,message) - if (upload_to_strava) or (w.user.strava_auto_export): + if (upload_to_strava) or (w.user.strava_auto_export and isprorower(w.user)): try: message,id = stravastuff.workout_strava_upload( request.user,w @@ -10540,7 +10537,7 @@ def workout_upload_view(request, else: messages.error(request,message) - if (upload_to_st) or (w.user.sporttracks_auto_export): + if (upload_to_st) or (w.user.sporttracks_auto_export and isprorower(w.user)): try: message,id = sporttracksstuff.workout_sporttracks_upload( request.user,w @@ -10553,7 +10550,7 @@ def workout_upload_view(request, else: messages.error(request,message) - if (upload_to_rk) or (w.user.runkeeper_auto_export): + if (upload_to_rk) or (w.user.runkeeper_auto_export and isprorower(w.user)): try: message,id = runkeeperstuff.workout_runkeeper_upload( request.user,w @@ -10568,7 +10565,7 @@ def workout_upload_view(request, messages.error(request,message) - if (upload_to_ua) or (w.user.mapmyfitness_auto_export): + if (upload_to_ua) or (w.user.mapmyfitness_auto_export and isprorower(w.user)): try: message,id = underarmourstuff.workout_ua_upload( request.user,w @@ -10583,7 +10580,7 @@ def workout_upload_view(request, messages.error(request,message) - if (upload_to_tp) or (w.user.trainingpeaks_auto_export): + if (upload_to_tp) or (w.user.trainingpeaks_auto_export and isprorower(w.user)): try: message,id = tpstuff.workout_tp_upload( request.user,w