excluding basic users from auto sync
This commit is contained in:
@@ -145,6 +145,8 @@ def get_polar_notifications():
|
|||||||
|
|
||||||
return available_data
|
return available_data
|
||||||
|
|
||||||
|
from rowers.utils import isprorower
|
||||||
|
|
||||||
def get_all_new_workouts(available_data,testing=False):
|
def get_all_new_workouts(available_data,testing=False):
|
||||||
for record in available_data:
|
for record in available_data:
|
||||||
if testing:
|
if testing:
|
||||||
@@ -153,7 +155,7 @@ def get_all_new_workouts(available_data,testing=False):
|
|||||||
try:
|
try:
|
||||||
r = Rower.objects.get(polaruserid=record['user-id'])
|
r = Rower.objects.get(polaruserid=record['user-id'])
|
||||||
u = r.user
|
u = r.user
|
||||||
if r.polar_auto_import:
|
if r.polar_auto_import and isprorower(r):
|
||||||
exercise_list = get_polar_workouts(u)
|
exercise_list = get_polar_workouts(u)
|
||||||
if testing:
|
if testing:
|
||||||
print exercise_list
|
print exercise_list
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
|
|
||||||
<h2>Auto Import/Export Settings</h2>
|
<h2>Auto Import/Export Settings</h2>
|
||||||
|
|
||||||
|
|
||||||
<p>Use the form below to set your auto import/export settings.
|
<p>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.</p>
|
As we implement auto import/export for various partner sites, this form will be expanded.</p>
|
||||||
|
|
||||||
@@ -112,6 +113,9 @@
|
|||||||
|
|
||||||
<p>Auto Export = New workouts uploaded to rowsandall.com will be automatically synchronized
|
<p>Auto Export = New workouts uploaded to rowsandall.com will be automatically synchronized
|
||||||
to the partner site</p>
|
to the partner site</p>
|
||||||
|
|
||||||
|
<p>These settings only have effect if you are a user on one
|
||||||
|
of the <a href="/rowers/promembership">paid plans</a></p>
|
||||||
|
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
<form id="importexportform" method="post">
|
<form id="importexportform" method="post">
|
||||||
@@ -124,6 +128,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,19 @@
|
|||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Import, Export, Synchronization and download of all your data</td>
|
<td>Manual Import, Export, Synchronization and download of all your data</td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Automatic Synchronization with other fitness sites</td>
|
||||||
|
<td> </td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>✔</td>
|
||||||
|
<td>✔</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Heart rate and power zones</td>
|
<td>Heart rate and power zones</td>
|
||||||
<td>✔</td>
|
<td>✔</td>
|
||||||
|
|||||||
@@ -373,15 +373,17 @@ def make_private(w,options):
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
from rowers.utils import isprorower
|
||||||
|
|
||||||
def do_sync(w,options):
|
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:
|
try:
|
||||||
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
||||||
except c2stuff.C2NoTokenError:
|
except c2stuff.C2NoTokenError:
|
||||||
id = 0
|
id = 0
|
||||||
message = "Something went wrong with the Concept2 sync"
|
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:
|
try:
|
||||||
message,id = stravastuff.workout_strava_upload(
|
message,id = stravastuff.workout_strava_upload(
|
||||||
w.user.user,w
|
w.user.user,w
|
||||||
@@ -391,7 +393,7 @@ def do_sync(w,options):
|
|||||||
message = "Please connect to Strava first"
|
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:
|
try:
|
||||||
message,id = sporttracksstuff.workout_sporttracks_upload(
|
message,id = sporttracksstuff.workout_sporttracks_upload(
|
||||||
w.user.user,w
|
w.user.user,w
|
||||||
@@ -401,7 +403,7 @@ def do_sync(w,options):
|
|||||||
id = 0
|
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:
|
try:
|
||||||
message,id = runkeeperstuff.workout_runkeeper_upload(
|
message,id = runkeeperstuff.workout_runkeeper_upload(
|
||||||
w.user.user,w
|
w.user.user,w
|
||||||
@@ -410,7 +412,7 @@ def do_sync(w,options):
|
|||||||
message = "Please connect to Runkeeper first"
|
message = "Please connect to Runkeeper first"
|
||||||
id = 0
|
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:
|
try:
|
||||||
message,id = underarmourstuff.workout_ua_upload(
|
message,id = underarmourstuff.workout_ua_upload(
|
||||||
w.user.user,w
|
w.user.user,w
|
||||||
@@ -420,7 +422,7 @@ def do_sync(w,options):
|
|||||||
id = 0
|
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:
|
try:
|
||||||
message,id = tpstuff.workout_tp_upload(
|
message,id = tpstuff.workout_tp_upload(
|
||||||
w.user.user,w
|
w.user.user,w
|
||||||
|
|||||||
@@ -369,3 +369,12 @@ def totaltime_sec_to_string(totaltime):
|
|||||||
duration = "%s:%s:%s.%s" % (hours, minutes, seconds, tenths)
|
duration = "%s:%s:%s.%s" % (hours, minutes, seconds, tenths)
|
||||||
|
|
||||||
return duration
|
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
|
||||||
|
|
||||||
|
|||||||
@@ -926,6 +926,8 @@ def hasplannedsessions(user):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
from rowers.utils import isprorower
|
||||||
|
|
||||||
# Check if a user is a Pro member
|
# Check if a user is a Pro member
|
||||||
def ispromember(user):
|
def ispromember(user):
|
||||||
if not user.is_anonymous():
|
if not user.is_anonymous():
|
||||||
@@ -934,10 +936,8 @@ def ispromember(user):
|
|||||||
except Rower.DoesNotExists:
|
except Rower.DoesNotExists:
|
||||||
r = Rower(user=user)
|
r = Rower(user=user)
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
result = user.is_authenticated() and (r.rowerplan=='pro' or r.rowerplan=='coach' or r.rowerplan=='plan')
|
result = user.is_authenticated() and isprorower(r)
|
||||||
if not result and r.protrialexpires:
|
|
||||||
result = user.is_authenticated() and r.rowerplan=='basic' and r.protrialexpires >= datetime.date.today()
|
|
||||||
else:
|
else:
|
||||||
result = False
|
result = False
|
||||||
return result
|
return result
|
||||||
@@ -2684,9 +2684,6 @@ def imports_view(request):
|
|||||||
|
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
# polar_auto_import = cd['polar_auto_import']
|
|
||||||
# r.polar_auto_import = polar_auto_import
|
|
||||||
# r.save()
|
|
||||||
else:
|
else:
|
||||||
form = RowerImportExportForm(instance=r)
|
form = RowerImportExportForm(instance=r)
|
||||||
|
|
||||||
@@ -10516,7 +10513,7 @@ def workout_upload_view(request,
|
|||||||
request.session['async_tasks'] = [(jobid,'make_plot')]
|
request.session['async_tasks'] = [(jobid,'make_plot')]
|
||||||
|
|
||||||
# upload to C2
|
# 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:
|
try:
|
||||||
message,id = c2stuff.workout_c2_upload(request.user,w)
|
message,id = c2stuff.workout_c2_upload(request.user,w)
|
||||||
except C2NoTokenError:
|
except C2NoTokenError:
|
||||||
@@ -10527,7 +10524,7 @@ def workout_upload_view(request,
|
|||||||
else:
|
else:
|
||||||
messages.error(request,message)
|
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:
|
try:
|
||||||
message,id = stravastuff.workout_strava_upload(
|
message,id = stravastuff.workout_strava_upload(
|
||||||
request.user,w
|
request.user,w
|
||||||
@@ -10540,7 +10537,7 @@ def workout_upload_view(request,
|
|||||||
else:
|
else:
|
||||||
messages.error(request,message)
|
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:
|
try:
|
||||||
message,id = sporttracksstuff.workout_sporttracks_upload(
|
message,id = sporttracksstuff.workout_sporttracks_upload(
|
||||||
request.user,w
|
request.user,w
|
||||||
@@ -10553,7 +10550,7 @@ def workout_upload_view(request,
|
|||||||
else:
|
else:
|
||||||
messages.error(request,message)
|
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:
|
try:
|
||||||
message,id = runkeeperstuff.workout_runkeeper_upload(
|
message,id = runkeeperstuff.workout_runkeeper_upload(
|
||||||
request.user,w
|
request.user,w
|
||||||
@@ -10568,7 +10565,7 @@ def workout_upload_view(request,
|
|||||||
messages.error(request,message)
|
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:
|
try:
|
||||||
message,id = underarmourstuff.workout_ua_upload(
|
message,id = underarmourstuff.workout_ua_upload(
|
||||||
request.user,w
|
request.user,w
|
||||||
@@ -10583,7 +10580,7 @@ def workout_upload_view(request,
|
|||||||
messages.error(request,message)
|
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:
|
try:
|
||||||
message,id = tpstuff.workout_tp_upload(
|
message,id = tpstuff.workout_tp_upload(
|
||||||
request.user,w
|
request.user,w
|
||||||
|
|||||||
Reference in New Issue
Block a user