Private
Public Access
1
0

Merge branch 'develop' into feature/opaqueid

This commit is contained in:
Sander Roosendaal
2019-01-25 08:35:38 +01:00
73 changed files with 59990 additions and 2468 deletions

View File

@@ -13,6 +13,7 @@ from django_mailbox.models import Message, MessageAttachment,Mailbox
from django.core.urlresolvers import reverse
from django.conf import settings
from django.utils import timezone
from rowers.models import Workout, Rower
from rowingdata import rower as rrower
@@ -24,6 +25,11 @@ import rowers.polarstuff as polarstuff
import rowers.c2stuff as c2stuff
import rowers.stravastuff as stravastuff
from rowers.opaque import encoder
from rowers.models import User,VirtualRace,Workout
from rowers.plannedsessions import email_submit_race
workoutmailbox = Mailbox.objects.get(name='workouts')
failedmailbox = Mailbox.objects.get(name='Failed')
@@ -65,17 +71,42 @@ 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 'raceid' in uploadoptions and workoutid[0] and rower.user.is_staff:
if testing and workoutid[0]:
w = Workout.objects.get(id = workoutid[0])
w.startdatetime = timezone.now()
w.date = timezone.now().date()
w.save()
try:
race = VirtualRace.objects.get(id=uploadoptions['raceid'])
if race.manager == rower.user:
result = email_submit_race(therower,race,workoutid[0])
except VirtualRace.DoesNotExist:
pass
if testing:
print 'Workout id = {workoutid}'.format(workoutid=workoutid)
if workoutid[0]:
link = settings.SITE_URL+reverse(
rower.defaultlandingpage,
therower.defaultlandingpage,
kwargs = {
'id':encoder.encode_hex(workoutid[0]),
}
@@ -99,9 +130,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 +140,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: