Private
Public Access
1
0

kml email working

This commit is contained in:
Sander Roosendaal
2018-06-06 14:23:10 +02:00
parent 77702aba7c
commit aed878d677
5 changed files with 81 additions and 0 deletions

View File

@@ -132,6 +132,7 @@ from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,
from rowers.tasks import (
handle_sendemail_unrecognized,handle_sendemailnewcomment,
handle_sendemailsummary,
handle_sendemailkml,
handle_sendemailnewresponse, handle_updatedps,
handle_updatecp,long_test_task,long_test_task2,
handle_zip_file,handle_getagegrouprecords,
@@ -1847,6 +1848,48 @@ def workout_tcxemail_view(request,id=0):
return response
@login_required()
def course_kmlemail_view(request,id=0):
r = getrower(request.user)
if r.emailbounced:
message = "Please check your email address first. Email to this address bounced."
messages.error(request,message)
return HttpResponseRedirect(
reverse(course_view,
kwargs = {
'id':str(id),
})
)
course = GeoCourse.objects.get(id=id)
kmlstring = courses.coursetokml(course)
kmlfilename = 'course_{id}.kml'.format(id=id)
with open(kmlfilename,'w') as fop:
fop.write(kmlstring)
res = myqueue(queuehigh,handle_sendemailkml,
r.user.first_name,
r.user.last_name,
r.user.email,kmlfilename,
emailbounced = r.emailbounced
)
successmessage = "The KML file was sent to you per email"
messages.info(request,successmessage)
url = reverse(course_view,
kwargs = {
'id':str(id),
})
response = HttpResponseRedirect(url)
return response
# Export workout to GPX and send to user's email address
@login_required()
def workout_gpxemail_view(request,id=0):