works now - send workout to email message
This commit is contained in:
@@ -47,6 +47,8 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
filename = fileobj.name
|
||||
except AttributeError:
|
||||
filename = fileobj[6:]
|
||||
if testing:
|
||||
print 'Attribute Error', filename
|
||||
|
||||
|
||||
# test if file exists and is not empty
|
||||
@@ -54,12 +56,20 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
with open('media/'+filename,'r') as fop:
|
||||
line = fop.readline()
|
||||
except IOError:
|
||||
if testing:
|
||||
print 'IOError',filename,'media/'+filename
|
||||
return 0
|
||||
|
||||
if testing:
|
||||
print 'Creating workout from email'
|
||||
|
||||
workoutid = [
|
||||
make_new_workout_from_email(rower, filename, title,testing=testing)
|
||||
]
|
||||
|
||||
if testing:
|
||||
print 'Workout id = {workoutid}'.format(workoutid=workoutid)
|
||||
|
||||
if workoutid[0]:
|
||||
link = settings.SITE_URL+reverse(
|
||||
rower.defaultlandingpage,
|
||||
@@ -185,6 +195,9 @@ class Command(BaseCommand):
|
||||
)
|
||||
else:
|
||||
# move attachment and make workout
|
||||
if testing:
|
||||
print name
|
||||
print attachment.document
|
||||
workoutid = processattachment(
|
||||
rower, attachment.document, name, uploadoptions,
|
||||
testing=testing
|
||||
|
||||
Reference in New Issue
Block a user