From e8b12de581178bad60c749c4719bb531b23540e3 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 2 Sep 2024 08:13:05 -0700 Subject: [PATCH] clean up --- app/main/views/platform_admin.py | 8 ++++---- app/main/views/send.py | 16 ++++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index 820287675..17ca7d621 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -34,7 +34,7 @@ from app.main.forms import ( DateFilterForm, RequiredDateFilterForm, ) -from app.main.views.send import _send_notification, send_notification +from app.main.views.send import _send_notification from app.statistics_utils import ( get_formatted_percentage, get_formatted_percentage_two_dp, @@ -46,7 +46,7 @@ from app.utils.pagination import ( generate_previous_dict, get_page_from_request, ) -from app.utils.user import user_has_permissions, user_is_platform_admin +from app.utils.user import user_is_platform_admin COMPLAINT_THRESHOLD = 0.02 FAILURE_THRESHOLD = 3 @@ -851,8 +851,8 @@ def _prepare_load_test_service(service): user_api_client.add_user_to_service( service["id"], user["id"], ["send messages"] ) - except Exception as e: - current_app.logger.warning( + except Exception: + current_app.logger.exception( f"Couldnt add user, may already be part of service" ) pass diff --git a/app/main/views/send.py b/app/main/views/send.py index dc33cdbd9..eda5ae8fc 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -996,10 +996,8 @@ def send_notification(service_id, template_id): def _send_notification(service_id, template_id): - print(hilite(f"ENTER SEND NOTIFICATION")) scheduled_for = session.pop("scheduled_for", "") recipient = get_recipient() - print(hilite(f"RECIPIENT {recipient}")) if not recipient: return redirect( @@ -1019,14 +1017,11 @@ def _send_notification(service_id, template_id): data = ",".join(keys) vals = ",".join(values) data = f"{data}\r\n{vals}" - print(hilite(f"DATA {data}")) - filename = ( f"one-off-{uuid.uuid4()}.csv" # {current_user.name} removed from filename ) my_data = {"filename": filename, "template_id": template_id, "data": data} upload_id = s3upload(service_id, my_data) - print(hilite(f"UPLOAD ID {upload_id}")) # To debug messages that the user reports have not been sent, we log # the csv filename and the job id. The user will give us the file name, # so we can search on that to obtain the job id, which we can use elsewhere @@ -1040,15 +1035,12 @@ def _send_notification(service_id, template_id): form = CsvUploadForm() form.file.data = my_data form.file.name = filename - print(f"POPULATED FORM") - print(f"USER PERMISSIONS {current_user.permissions[service_id]}") # TODO IF RUNNING LOAD TEST WE DONT NEED - # check_message_output = check_messages(service_id, template_id, upload_id, 2) - # print(hilite(hilite(f"CHECK MESSAGE OUTPUT {check_message_output}"))) - # if "You cannot send to" in check_message_output: - # return check_messages(service_id, template_id, upload_id, 2) + check_message_output = check_messages(service_id, template_id, upload_id, 2) + print(hilite(hilite(f"CHECK MESSAGE OUTPUT {check_message_output}"))) + if "You cannot send to" in check_message_output: + return check_messages(service_id, template_id, upload_id, 2) - print(f"GOING TO CREATE JOB") job_api_client.create_job( upload_id, service_id,