adding FIT export
This commit is contained in:
@@ -260,6 +260,11 @@
|
|||||||
TCX
|
TCX
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li id="export-fit">
|
||||||
|
<a href="/rowers/workout/{{ workout.id|encode }}/emailfit/">
|
||||||
|
FIT
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="has-children" id="data">
|
<li class="has-children" id="data">
|
||||||
|
|||||||
@@ -494,6 +494,8 @@ urlpatterns = [
|
|||||||
name='workout_comment_view'),
|
name='workout_comment_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailtcx/$', views.workout_tcxemail_view,
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailtcx/$', views.workout_tcxemail_view,
|
||||||
name='workout_tcxemail_view'),
|
name='workout_tcxemail_view'),
|
||||||
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailfit/$', views.workout_fitemail_view,
|
||||||
|
name='workout_fitemail_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailgpx/$', views.workout_gpxemail_view,
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailgpx/$', views.workout_gpxemail_view,
|
||||||
name='workout_gpxemail_view'),
|
name='workout_gpxemail_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailcsv/$', views.workout_csvemail_view,
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/emailcsv/$', views.workout_csvemail_view,
|
||||||
|
|||||||
@@ -22,6 +22,27 @@ def workout_tcxemail_view(request, id=0):
|
|||||||
os.remove(tcxfilename)
|
os.remove(tcxfilename)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@permission_required('workout.change_workout', fn=get_workout_by_opaqueid, raise_exception=True)
|
||||||
|
def workout_fitemail_view(request, id=0):
|
||||||
|
w = get_workout(id)
|
||||||
|
|
||||||
|
row = rdata(csvfile=w.csvfilename)
|
||||||
|
|
||||||
|
code = str(uuid4())
|
||||||
|
fitfilename = code+'.fit'
|
||||||
|
|
||||||
|
workouttype = mytypes.fitmapping.get(w.workouttype, 'generic')
|
||||||
|
|
||||||
|
row.exporttofit(fitfilename, sport=workouttype, notes=w.name)
|
||||||
|
|
||||||
|
with open(fitfilename, 'rb') as f:
|
||||||
|
response = HttpResponse(f)
|
||||||
|
response['Content-Disposition'] = 'attachment; filename="%s"' % fitfilename
|
||||||
|
response['Content-Type'] = 'application/octet-stream'
|
||||||
|
|
||||||
|
os.remove(fitfilename)
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def plannedsessions_icsemail_view(request, userid=0):
|
def plannedsessions_icsemail_view(request, userid=0):
|
||||||
|
|||||||
Reference in New Issue
Block a user