added links to strava, st, c2 under button
This commit is contained in:
@@ -449,6 +449,7 @@ def get_username(access_token):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
res = me_json['data']['username']
|
res = me_json['data']['username']
|
||||||
|
id = me_json['data']['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res = None
|
res = None
|
||||||
|
|
||||||
@@ -482,7 +483,7 @@ def process_callback(request):
|
|||||||
|
|
||||||
access_token = get_token(code)
|
access_token = get_token(code)
|
||||||
|
|
||||||
username = get_username(access_token)
|
username,id = get_username(access_token)
|
||||||
|
|
||||||
return HttpResponse("got a user name: %s" % username)
|
return HttpResponse("got a user name: %s" % username)
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
|||||||
|
|
||||||
act = client.upload_activity(f2,'tcx',name=workoutname)
|
act = client.upload_activity(f2,'tcx',name=workoutname)
|
||||||
try:
|
try:
|
||||||
res = act.wait(poll_interval=5.0)
|
res = act.wait(poll_interval=5.0,timeout=30)
|
||||||
message = 'Workout successfully synchronized to Strava'
|
message = 'Workout successfully synchronized to Strava'
|
||||||
except:
|
except:
|
||||||
res = 0
|
res = 0
|
||||||
@@ -246,6 +246,7 @@ def handle_stravaexport(f2,workoutname,stravatoken,description=''):
|
|||||||
act = client.update_activity(res.id,activity_type='Rowing',description=description)
|
act = client.update_activity(res.id,activity_type='Rowing',description=description)
|
||||||
else:
|
else:
|
||||||
message = 'Strava upload timed out.'
|
message = 'Strava upload timed out.'
|
||||||
|
return (0,message)
|
||||||
|
|
||||||
return (res.id,message)
|
return (res.id,message)
|
||||||
|
|
||||||
|
|||||||
@@ -13,23 +13,23 @@
|
|||||||
<div class="grid_2 alpha">
|
<div class="grid_2 alpha">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/edit">Edit Workout</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_2 suffix_2 omega">
|
<div class="grid_2 suffix_2 omega">
|
||||||
<p>
|
<p>
|
||||||
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
<a class="button gray small" href="/rowers/workout/{{ workout.id }}/advanced">Advanced Edit</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
<p>
|
<p>
|
||||||
Click on the icon to upload this workout to your site of choice. A checkmark indicates that the workout has already been uploaded. If the button is grayed out, click it to authorize the connection to that site. Use TCX or CSV export to email a TCX or CSV file of your workout to yourself.
|
Click on the icon to upload this workout to your site of choice. A checkmark indicates that the workout has already been uploaded. If the button is grayed out, click it to authorize the connection to that site. Use TCX or CSV export to email a TCX or CSV file of your workout to yourself.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if workout.uploadedtoc2 == 0 %}
|
{% if workout.uploadedtoc2 == 0 %}
|
||||||
{% if user.rower.c2token == None or user.rower.c2token == '' %}
|
{% if user.rower.c2token == None or user.rower.c2token == '' %}
|
||||||
<div class="grid_1 alpha">
|
<div class="grid_1 alpha">
|
||||||
<a href="/rowers/me/c2authorize">
|
<a href="/rowers/me/c2authorize">
|
||||||
@@ -40,54 +40,57 @@ Click on the icon to upload this workout to your site of choice. A checkmark ind
|
|||||||
<a href="/rowers/workout/{{ workout.id }}/c2uploadw"><img src="/static/img/c2square.jpg" alt="Concept2 icon" width="60" height="60"></a>
|
<a href="/rowers/workout/{{ workout.id }}/c2uploadw"><img src="/static/img/c2square.jpg" alt="Concept2 icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_1 alpha">
|
<div class="grid_1 alpha">
|
||||||
|
<a href="http://log.concept2.com/profile/{{ c2userid }}/log/{{ workout.uploadedtoc2 }}">
|
||||||
<img src="/static/img/c2square_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
<img src="/static/img/c2square_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if workout.uploadedtostrava == 0 %}
|
{% if workout.uploadedtostrava == 0 %}
|
||||||
{% if user.rower.stravatoken == None or user.rower.stravatoken == '' %}
|
{% if user.rower.stravatoken == None or user.rower.stravatoken == '' %}
|
||||||
<div class="grid_1">
|
<div class="grid_1">
|
||||||
<a href="/rowers/me/stravaauthorize">
|
<a href="/rowers/me/stravaauthorize">
|
||||||
<img src="/static/img/stravasquare_gray.png" alt="Strava icon" width="60" height="60"></a>
|
<img src="/static/img/stravasquare_gray.png" alt="Strava icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
|
||||||
<div class="grid_1">
|
|
||||||
<a href="/rowers/workout/{{ workout.id }}/stravauploadw"><img src="/static/img/stravasquare.png" alt="Strava icon" width="60" height="60"></a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_1">
|
<div class="grid_1">
|
||||||
|
<a href="/rowers/workout/{{ workout.id }}/stravauploadw"><img src="/static/img/stravasquare.png" alt="Strava icon" width="60" height="60"></a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<div class="grid_1">
|
||||||
|
<a href="https://www.strava.com/activities/{{ workout.uploadedtostrava }}">
|
||||||
<img src="/static/img/stravasquare_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
<img src="/static/img/stravasquare_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if workout.uploadedtosporttracks == 0 %}
|
{% if workout.uploadedtosporttracks == 0 %}
|
||||||
{% if user.rower.sporttrackstoken == None or user.rower.sporttrackstoken == '' %}
|
{% if user.rower.sporttrackstoken == None or user.rower.sporttrackstoken == '' %}
|
||||||
<div class="grid_1">
|
<div class="grid_1">
|
||||||
<a href="/rowers/me/sporttracksauthorize">
|
<a href="/rowers/me/sporttracksauthorize">
|
||||||
<img src="/static/img/sporttrackssquare_gray.png" alt="SportTracks icon" width="60" height="60"></a>
|
<img src="/static/img/sporttrackssquare_gray.png" alt="SportTracks icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="grid_1">
|
<div class="grid_1">
|
||||||
<a href="/rowers/workout/{{ workout.id }}/sporttracksuploadw">
|
<a href="/rowers/workout/{{ workout.id }}/sporttracksuploadw">
|
||||||
<img src="/static/img/sporttrackssquare.png" alt="SportTracks icon" width="60" height="60"></a>
|
<img src="/static/img/sporttrackssquare.png" alt="SportTracks icon" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<div class="grid_1">
|
|
||||||
<img src="/static/img/sporttrackssquare_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="grid_1">
|
{% else %}
|
||||||
|
<div class="grid_1">
|
||||||
|
<a href="https://sporttracks.mobi/activity/{{ workout.uploadedtosporttracks }}">
|
||||||
|
<img src="/static/img/sporttrackssquare_checked.png" alt="Concept2 icon" width="60" height="60"></a>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="grid_1">
|
||||||
<a href="/rowers/workout/{{ workout.id }}/emailtcx">
|
<a href="/rowers/workout/{{ workout.id }}/emailtcx">
|
||||||
<img src="/static/img/export.png" alt="TCX Export" width="60" height="60"></a>
|
<img src="/static/img/export.png" alt="TCX Export" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid_1">
|
<div class="grid_1">
|
||||||
<a href="/rowers/workout/{{ workout.id }}/emailcsv">
|
<a href="/rowers/workout/{{ workout.id }}/emailcsv">
|
||||||
<img src="/static/img/CSVsquare.png" alt="CSV Export" width="60" height="60"></a>
|
<img src="/static/img/CSVsquare.png" alt="CSV Export" width="60" height="60"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -810,7 +810,10 @@ def workout_strava_upload_view(request,id=0):
|
|||||||
message = mes
|
message = mes
|
||||||
w.uploadedtostrava = -1
|
w.uploadedtostrava = -1
|
||||||
w.save()
|
w.save()
|
||||||
|
try:
|
||||||
os.remove(tcxfile)
|
os.remove(tcxfile)
|
||||||
|
except WindowsError:
|
||||||
|
pass
|
||||||
url = reverse(workout_export_view,
|
url = reverse(workout_export_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'id':str(w.id),
|
'id':str(w.id),
|
||||||
@@ -3423,6 +3426,16 @@ def workout_export_view(request,id=0, message="", successmessage=""):
|
|||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
raise Http404("Workout doesn't exist")
|
raise Http404("Workout doesn't exist")
|
||||||
|
|
||||||
|
try:
|
||||||
|
thetoken = c2_open(request.user)
|
||||||
|
except C2NoTokenError:
|
||||||
|
thetoken = 0
|
||||||
|
|
||||||
|
if (checkworkoutuser(request.user,row)) and thetoken:
|
||||||
|
c2userid = c2stuff.get_userid(thetoken)
|
||||||
|
else:
|
||||||
|
c2userid = 0
|
||||||
|
|
||||||
form = WorkoutForm(instance=row)
|
form = WorkoutForm(instance=row)
|
||||||
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
|
||||||
@@ -3439,6 +3452,7 @@ def workout_export_view(request,id=0, message="", successmessage=""):
|
|||||||
'export.html',
|
'export.html',
|
||||||
{'workout':row,
|
{'workout':row,
|
||||||
'message':message,
|
'message':message,
|
||||||
|
'successmessage':successmessage,
|
||||||
'c2userid':c2userid,
|
'c2userid':c2userid,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user