From 13f7fecd5b42d08a2102d31455d5ebec2a5c2b32 Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Fri, 22 May 2020 09:36:07 +0100 Subject: [PATCH] Move function to get archived email address value This function will be used when archiving services too, so it has been renamed and moved to `app/utils.py`. --- app/dao/users_dao.py | 9 ++------- app/utils.py | 5 +++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/dao/users_dao.py b/app/dao/users_dao.py index 3e3924acd..33acd854a 100644 --- a/app/dao/users_dao.py +++ b/app/dao/users_dao.py @@ -11,7 +11,7 @@ from app.dao.service_user_dao import dao_get_service_users_by_user_id from app.dao.dao_utils import transactional from app.errors import InvalidRequest from app.models import (EMAIL_AUTH_TYPE, User, VerifyCode) -from app.utils import escape_special_characters +from app.utils import escape_special_characters, get_archived_db_column_value def _remove_values_for_keys_if_present(dict, keys): @@ -161,7 +161,7 @@ def dao_archive_user(user): user.organisations = [] user.auth_type = EMAIL_AUTH_TYPE - user.email_address = get_archived_email_address(user.email_address) + user.email_address = get_archived_db_column_value(user.email_address) user.mobile_number = None user.password = str(uuid.uuid4()) # Changing the current_session_id signs the user out @@ -185,8 +185,3 @@ def user_can_be_archived(user): return False return True - - -def get_archived_email_address(email_address): - date = datetime.utcnow().strftime("%Y-%m-%d") - return '_archived_{}_{}'.format(date, email_address) diff --git a/app/utils.py b/app/utils.py index 9c9fe915a..e4066c3cb 100644 --- a/app/utils.py +++ b/app/utils.py @@ -126,3 +126,8 @@ def get_notification_table_to_use(service, notification_type, process_day, has_d days_of_retention += 1 return Notification if days_ago <= timedelta(days=days_of_retention) else NotificationHistory + + +def get_archived_db_column_value(column): + date = datetime.utcnow().strftime("%Y-%m-%d") + return f'_archived_{date}_{column}'