Private
Public Access
1
0

Email confirmations for workouts received

This commit is contained in:
Sander Roosendaal
2016-11-18 13:52:22 +01:00
parent 439bca2f9c
commit ae7b7fb9ab
2 changed files with 29 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ from rowers.tasks import handle_sendemail_unrecognized
from django_mailbox.models import Mailbox,Message,MessageAttachment
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage,AdvancedWorkoutForm
from django.core.files.base import ContentFile
from django.core.mail import send_mail, BadHeaderError,EmailMessage
from rowsandall_app.settings import BASE_DIR
from rowingdata import rower as rrower
@@ -19,6 +19,22 @@ from rowingdata import summarydata,get_file_type
from scipy.signal import savgol_filter
def send_confirm(u,name,link):
fullemail = u.email
subject = 'Workout added: '+name
message = 'Dear '+u.first_name+',\n\n'
message += "Your workout has been added to Rowsandall.com.\n"
message += "Link to workout: "+link+"\n\n"
message += "Best Regards, the Rowsandall Team"
email = EmailMessage(subject,message,
'Rowsandall <info@rowsandall.com>',
[fullemail])
res = email.send()
return 1
def rdata(file,rower=rrower()):
try:
res = rrdata(file,rower=rower)
@@ -49,7 +65,11 @@ def processattachments():
rr = Rower.objects.get(user=u.id)
# move attachment and make workout
try:
res += [make_new_workout_from_email(rr,a.document,name)]
wid = [make_new_workout_from_email(rr,a.document,name)]
res += wid
print wid
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
dd = send_confirm(u,name,link)
except:
# replace with code to process error
res += ['fail: '+name]
@@ -221,7 +241,7 @@ def make_new_workout_from_email(rr,f2,name,cntr=0):
startdatetime=row.rowdatetime)
w.save()
return 1
return w.id