kml email working
This commit is contained in:
@@ -749,6 +749,27 @@ def handle_sendemail_unrecognizedowner(useremail, userfirstname,
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemailkml(first_name, last_name, email, kmlfile,**kwargs):
|
||||
|
||||
# send email with attachment
|
||||
fullemail = first_name + " " + last_name + " " + "<" + email + ">"
|
||||
subject = "File from Rowsandall.com"
|
||||
|
||||
|
||||
d = {'first_name':first_name,
|
||||
'siteurl':siteurl,
|
||||
}
|
||||
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
|
||||
res = send_template_email(from_email,[fullemail],
|
||||
subject,'kmlemail.html',d,
|
||||
attach_file=kmlfile,**kwargs)
|
||||
|
||||
os.remove(kmlfile)
|
||||
return 1
|
||||
|
||||
# Send email with TCX attachment
|
||||
@app.task
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
<div class="grid_2">
|
||||
<a class="button small gray" href="/rowers/list-courses">Courses</a>
|
||||
</div>
|
||||
<div class="grid_2">
|
||||
<a class="button small gray" href="/rowers/courses/{{ course.id }}/emailkml">Export to KML</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
|
||||
|
||||
13
rowers/templates/kmlemail.html
Normal file
13
rowers/templates/kmlemail.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "emailbase.html" %}
|
||||
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
Please find attached the requested KML course file. You can open this file in Google Earth
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -518,6 +518,7 @@ urlpatterns = [
|
||||
url(r'^courses/(?P<id>\d+)/edit$',views.course_edit_view,
|
||||
name='course_edit_view'),
|
||||
url(r'^courses/(?P<id>\d+)/delete$',views.course_delete_view),
|
||||
url(r'^courses/(?P<id>\d+)/emailkml$',views.course_kmlemail_view),
|
||||
url(r'^courses/(?P<id>\d+)/replace$',views.course_replace_view),
|
||||
url(r'^courses/(?P<id>\d+)$',views.course_view),
|
||||
url(r'^courses/(?P<id>\d+)/map$',views.course_map_view),
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user