Private
Public Access
1
0

now passing all tests

This commit is contained in:
Sander Roosendaal
2019-07-24 09:49:48 +02:00
parent 20b1f4ec03
commit da6934ec0c
3 changed files with 34 additions and 18 deletions

View File

@@ -34,8 +34,6 @@ 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')
# If you find a solution that does not need the two paths, please comment!
sys.path.append('$path_to_root_of_project$')
@@ -189,9 +187,31 @@ class Command(BaseCommand):
default=False,
help="Run in testing mode, don't send emails",
)
parser.add_argument(
'--mailbox',
action='store_true',
dest='mailbox',
default='workouts',
help="Changing mailbox name",
)
"""Run the Email processing command """
def handle(self, *args, **options):
if 'testing' in options:
testing = options['testing']
else:
testing = False
if 'mailbox' in options:
workoutmailbox = Mailbox.objects.get(name=options['mailbox'])
else:
workoutmailbox = Mailbox.objects.get(name='workouts')
if 'failedmailbox' in options:
failedmailbox = Mailbox.objects.get(name=options['failedmailbox'])
else:
failedmailbox = Mailbox.objects.get(name='Failed')
# Polar
polar_available = polarstuff.get_polar_notifications()
res = polarstuff.get_all_new_workouts(polar_available)
@@ -207,10 +227,6 @@ class Command(BaseCommand):
attachments = MessageAttachment.objects.filter(
message_id__in=message_ids
)
if 'testing' in options:
testing = options['testing']
else:
testing = False
cntr = 0
for attachment in attachments:
filename, extension = os.path.splitext(attachment.document.name)