passing test for user
This commit is contained in:
@@ -23,6 +23,7 @@ from rowers.mailprocessing import make_new_workout_from_email, send_confirm
|
||||
import rowers.polarstuff as polarstuff
|
||||
import rowers.c2stuff as c2stuff
|
||||
import rowers.stravastuff as stravastuff
|
||||
from rowers.models import User
|
||||
|
||||
workoutmailbox = Mailbox.objects.get(name='workouts')
|
||||
failedmailbox = Mailbox.objects.get(name='Failed')
|
||||
@@ -65,9 +66,20 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
|
||||
if testing:
|
||||
print 'Creating workout from email'
|
||||
|
||||
# set user
|
||||
if rower.user.is_staff and 'username' in uploadoptions:
|
||||
users = User.objects.filter(username=uploadoptions['username'])
|
||||
if len(users)==1:
|
||||
therower = users[0].rower
|
||||
else:
|
||||
return 0
|
||||
else:
|
||||
therower = rower
|
||||
|
||||
|
||||
workoutid = [
|
||||
make_new_workout_from_email(rower, filename, title,testing=testing)
|
||||
make_new_workout_from_email(therower, filename, title,testing=testing)
|
||||
]
|
||||
|
||||
if testing:
|
||||
@@ -75,7 +87,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
|
||||
if workoutid[0]:
|
||||
link = settings.SITE_URL+reverse(
|
||||
rower.defaultlandingpage,
|
||||
therower.defaultlandingpage,
|
||||
kwargs = {
|
||||
'id':workoutid[0],
|
||||
}
|
||||
@@ -99,9 +111,9 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
)
|
||||
try:
|
||||
if workoutid and not testing:
|
||||
if rower.getemailnotifications and not rower.emailbounced:
|
||||
if therower.getemailnotifications and not therower.emailbounced:
|
||||
email_sent = send_confirm(
|
||||
rower.user, title, link,
|
||||
therower.user, title, link,
|
||||
uploadoptions
|
||||
)
|
||||
time.sleep(10)
|
||||
@@ -109,9 +121,9 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
try:
|
||||
time.sleep(10)
|
||||
if workoutid:
|
||||
if rower.getemailnotifications and not rower.emailbounced:
|
||||
if therower.getemailnotifications and not therower.emailbounced:
|
||||
email_sent = send_confirm(
|
||||
rower.user, title, link,
|
||||
therower.user, title, link,
|
||||
uploadoptions
|
||||
)
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user