Email confirmations for workouts received
This commit is contained in:
@@ -4,7 +4,7 @@ from rowers.tasks import handle_sendemail_unrecognized
|
|||||||
from django_mailbox.models import Mailbox,Message,MessageAttachment
|
from django_mailbox.models import Mailbox,Message,MessageAttachment
|
||||||
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage,AdvancedWorkoutForm
|
from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage,AdvancedWorkoutForm
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
|
from django.core.mail import send_mail, BadHeaderError,EmailMessage
|
||||||
from rowsandall_app.settings import BASE_DIR
|
from rowsandall_app.settings import BASE_DIR
|
||||||
|
|
||||||
from rowingdata import rower as rrower
|
from rowingdata import rower as rrower
|
||||||
@@ -19,6 +19,22 @@ from rowingdata import summarydata,get_file_type
|
|||||||
|
|
||||||
from scipy.signal import savgol_filter
|
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()):
|
def rdata(file,rower=rrower()):
|
||||||
try:
|
try:
|
||||||
res = rrdata(file,rower=rower)
|
res = rrdata(file,rower=rower)
|
||||||
@@ -49,7 +65,11 @@ def processattachments():
|
|||||||
rr = Rower.objects.get(user=u.id)
|
rr = Rower.objects.get(user=u.id)
|
||||||
# move attachment and make workout
|
# move attachment and make workout
|
||||||
try:
|
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:
|
except:
|
||||||
# replace with code to process error
|
# replace with code to process error
|
||||||
res += ['fail: '+name]
|
res += ['fail: '+name]
|
||||||
@@ -221,7 +241,7 @@ def make_new_workout_from_email(rr,f2,name,cntr=0):
|
|||||||
startdatetime=row.rowdatetime)
|
startdatetime=row.rowdatetime)
|
||||||
|
|
||||||
w.save()
|
w.save()
|
||||||
return 1
|
return w.id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from rowingdata import make_cumvalues
|
|||||||
from rowingdata import summarydata,get_file_type
|
from rowingdata import summarydata,get_file_type
|
||||||
|
|
||||||
from scipy.signal import savgol_filter
|
from scipy.signal import savgol_filter
|
||||||
from rowers.mailprocessing import make_new_workout_from_email
|
from rowers.mailprocessing import make_new_workout_from_email,send_confirm
|
||||||
|
|
||||||
def rdata(file,rower=rrower()):
|
def rdata(file,rower=rrower()):
|
||||||
try:
|
try:
|
||||||
@@ -60,7 +60,11 @@ class Command(BaseCommand):
|
|||||||
rr = Rower.objects.get(user=u.id)
|
rr = Rower.objects.get(user=u.id)
|
||||||
# move attachment and make workout
|
# move attachment and make workout
|
||||||
try:
|
try:
|
||||||
res += [make_new_workout_from_email(rr,a.document,name,cntr=cntr)]
|
wid = [make_new_workout_from_email(rr,a.document,name)]
|
||||||
|
res += wid
|
||||||
|
link = 'http://rowsandall.com/rowers/workout/'+str(wid[0])+'/edit'
|
||||||
|
dd = send_confirm(u,name,link)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
# replace with code to process error
|
# replace with code to process error
|
||||||
res += ['fail: '+name]
|
res += ['fail: '+name]
|
||||||
|
|||||||
Reference in New Issue
Block a user