From 6bdcbd2d21bafd0bd286c24efc913bf9aadff885 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 16 Feb 2020 19:56:46 +0100 Subject: [PATCH 1/2] email confirmations --- rowers/interactiveplots.py | 9 ++++++--- rowers/views/workoutviews.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 73c72151..5dcc988f 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -4329,9 +4329,12 @@ def thumbnails_set(r,id,favorites): l = len(rowdata) maxlength = 50 if l > maxlength: - bins = np.linspace(rowdata['time'].min(),rowdata['time'].max(),maxlength) - groups = rowdata.groupby(np.digitize(rowdata['time'],bins)) - rowdata = groups.mean() + try: + bins = np.linspace(rowdata['time'].min(),rowdata['time'].max(),maxlength) + groups = rowdata.groupby(np.digitize(rowdata['time'],bins)) + rowdata = groups.mean() + except KeyError: + pass for f in favorites: workstrokesonly = not f.reststrokes diff --git a/rowers/views/workoutviews.py b/rowers/views/workoutviews.py index f1f90da5..425df7b8 100644 --- a/rowers/views/workoutviews.py +++ b/rowers/views/workoutviews.py @@ -4424,6 +4424,7 @@ def workout_upload_api(request): optionsform = TeamUploadOptionsForm(post_data) rowerform = TeamInviteForm(post_data) rowerform.fields.pop('email') + fstr = '' try: fstr = post_data['file'] nn, ext = os.path.splitext(fstr) @@ -4531,9 +4532,22 @@ def workout_upload_api(request): pass else: # form invalid + if fstr: + os.remove(fstr) message = form.errors return JSONResponse(status=400,data=message) + if fstr: + os.remove(fstr) + + if r.getemailnotifications and not r.emailbounced: + link = settings.SITE_URL+reverse( + therower.defaultlandingpage, + kwargs = { + 'id':encoder.encode_hex(w.id), + } + ) + email_sent = send_confirm(r.user, t, link, '') message = {'status': 'true','id':w.id} return JSONResponse(status=200,data=message) From e337ea2ae419c640e80d3d54a868e985d5d46bf8 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sun, 16 Feb 2020 19:57:52 +0100 Subject: [PATCH 2/2] moving email confiram --- rowers/management/commands/processemail.py | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index c2124dab..54a39de5 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -132,20 +132,20 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False): if testing: print('Workout id = {workoutid}'.format(workoutid=workoutid)) - if workoutid[0]: - link = settings.SITE_URL+reverse( - therower.defaultlandingpage, - kwargs = { - 'id':encoder.encode_hex(workoutid[0]), - } - ) - - if not testing: - if therower.getemailnotifications and not therower.emailbounced: - email_sent = send_confirm( - therower.user, title, link, - uploadoptions - ) + # if workoutid[0]: + # link = settings.SITE_URL+reverse( + # therower.defaultlandingpage, + # kwargs = { + # 'id':encoder.encode_hex(workoutid[0]), + # } + # ) + # + # if not testing: + # if therower.getemailnotifications and not therower.emailbounced: + # email_sent = send_confirm( + # therower.user, title, link, + # uploadoptions + # ) return workoutid