diff --git a/app/dao/service_callback_api_dao.py b/app/dao/service_callback_api_dao.py index 2a4f3ff3c..e9f42692d 100644 --- a/app/dao/service_callback_api_dao.py +++ b/app/dao/service_callback_api_dao.py @@ -2,9 +2,8 @@ from datetime import datetime from app import create_uuid, db from app.dao.dao_utils import autocommit, version_class +from app.enums import CallbackType from app.models import ( - COMPLAINT_CALLBACK_TYPE, - DELIVERY_STATUS_CALLBACK_TYPE, ServiceCallbackApi, ) @@ -40,13 +39,13 @@ def get_service_callback_api(service_callback_api_id, service_id): def get_service_delivery_status_callback_api_for_service(service_id): return ServiceCallbackApi.query.filter_by( - service_id=service_id, callback_type=DELIVERY_STATUS_CALLBACK_TYPE + service_id=service_id, callback_type=CallbackType.DELIVERY_STATUS, ).first() def get_service_complaint_callback_api_for_service(service_id): return ServiceCallbackApi.query.filter_by( - service_id=service_id, callback_type=COMPLAINT_CALLBACK_TYPE + service_id=service_id, callback_type=CallbackType.COMPLAINT, ).first() diff --git a/app/dao/users_dao.py b/app/dao/users_dao.py index 49e2c4d39..44098b1a6 100644 --- a/app/dao/users_dao.py +++ b/app/dao/users_dao.py @@ -9,8 +9,9 @@ from app import db from app.dao.dao_utils import autocommit from app.dao.permissions_dao import permission_dao from app.dao.service_user_dao import dao_get_service_users_by_user_id +from app.enums import AuthType from app.errors import InvalidRequest -from app.models import EMAIL_AUTH_TYPE, User, VerifyCode +from app.models import User, VerifyCode from app.utils import escape_special_characters, get_archived_db_column_value @@ -171,7 +172,7 @@ def dao_archive_user(user): user.organizations = [] - user.auth_type = EMAIL_AUTH_TYPE + user.auth_type = AuthType.EMAIL user.email_address = get_archived_db_column_value(user.email_address) user.mobile_number = None user.password = str(uuid.uuid4()) diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 9910bc0b4..03d3ed3cc 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -15,12 +15,8 @@ from app.celery.test_key_tasks import send_email_response, send_sms_response from app.dao.email_branding_dao import dao_get_email_branding_by_id from app.dao.notifications_dao import dao_update_notification from app.dao.provider_details_dao import get_provider_details_by_notification_type -from app.enums import NotificationStatus, NotificationType, KeyType +from app.enums import NotificationStatus, NotificationType, KeyType, BrandType from app.exceptions import NotificationTechnicalFailureException -from app.models import ( - BRANDING_BOTH, - BRANDING_ORG_BANNER, -) from app.serialised_models import SerialisedService, SerialisedTemplate @@ -231,8 +227,8 @@ def get_html_email_options(service): ) return { - "govuk_banner": branding.brand_type == BRANDING_BOTH, - "brand_banner": branding.brand_type == BRANDING_ORG_BANNER, + "govuk_banner": branding.brand_type == BrandType.BOTH, + "brand_banner": branding.brand_type == BrandType.ORG_BANNER, "brand_colour": branding.colour, "brand_logo": logo_url, "brand_text": branding.text, diff --git a/app/organization/organization_schema.py b/app/organization/organization_schema.py index fccfc1a8d..ad88fbeef 100644 --- a/app/organization/organization_schema.py +++ b/app/organization/organization_schema.py @@ -1,4 +1,4 @@ -from app.models import INVITED_USER_STATUS_TYPES, ORGANIZATION_TYPES +from app.enums import InvitedUserStatus, OrganizationType from app.schema_validation.definitions import uuid post_create_organization_schema = { @@ -8,7 +8,7 @@ post_create_organization_schema = { "properties": { "name": {"type": "string"}, "active": {"type": ["boolean", "null"]}, - "organization_type": {"enum": ORGANIZATION_TYPES}, + "organization_type": {"enum": [e.value for e in OrganizationType]}, }, "required": ["name", "organization_type"], } @@ -20,7 +20,7 @@ post_update_organization_schema = { "properties": { "name": {"type": ["string", "null"]}, "active": {"type": ["boolean", "null"]}, - "organization_type": {"enum": ORGANIZATION_TYPES}, + "organization_type": {"enum": [e.value for e in OrganizationType]}, }, "required": [], } @@ -51,6 +51,6 @@ post_update_invited_org_user_status_schema = { "$schema": "http://json-schema.org/draft-07/schema#", "description": "POST update organization invite schema", "type": "object", - "properties": {"status": {"enum": INVITED_USER_STATUS_TYPES}}, + "properties": {"status": {"enum": [e.value for e in InvitedUserStatus]}}, "required": ["status"], } diff --git a/app/service/callback_rest.py b/app/service/callback_rest.py index 94da0aead..ab25e3ca6 100644 --- a/app/service/callback_rest.py +++ b/app/service/callback_rest.py @@ -13,12 +13,9 @@ from app.dao.service_inbound_api_dao import ( reset_service_inbound_api, save_service_inbound_api, ) +from app.enums import CallbackType from app.errors import InvalidRequest, register_errors -from app.models import ( - DELIVERY_STATUS_CALLBACK_TYPE, - ServiceCallbackApi, - ServiceInboundApi, -) +from app.models import ServiceCallbackApi, ServiceInboundApi from app.schema_validation import validate from app.service.service_callback_api_schema import ( create_service_callback_api_schema, @@ -90,7 +87,7 @@ def create_service_callback_api(service_id): data = request.get_json() validate(data, create_service_callback_api_schema) data["service_id"] = service_id - data["callback_type"] = DELIVERY_STATUS_CALLBACK_TYPE + data["callback_type"] = CallbackType.DELIVERY_STATUS callback_api = ServiceCallbackApi(**data) try: save_service_callback_api(callback_api) diff --git a/app/service/send_notification.py b/app/service/send_notification.py index 4bf13bec0..d0a9914cb 100644 --- a/app/service/send_notification.py +++ b/app/service/send_notification.py @@ -6,8 +6,7 @@ from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id from app.dao.services_dao import dao_fetch_service_by_id from app.dao.templates_dao import dao_get_template_by_id_and_service_id from app.dao.users_dao import get_user_by_id -from app.enums import NotificationType, KeyType -from app.models import PRIORITY +from app.enums import NotificationType, KeyType, TemplateProcessType from app.notifications.process_notifications import ( persist_notification, send_notification_to_queue, @@ -81,7 +80,7 @@ def send_one_off_notification(service_id, post_data): client_reference=client_reference, ) - queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None + queue_name = QueueNames.PRIORITY if template.process_type == TemplateProcessType.PRIORITY else None send_notification_to_queue( notification=notification, diff --git a/app/utils.py b/app/utils.py index fc68acd86..833dce55f 100644 --- a/app/utils.py +++ b/app/utils.py @@ -78,13 +78,12 @@ def get_month_from_utc_column(column): def get_public_notify_type_text(notify_type, plural=False): - from app.enums import NotificationType - from app.models import UPLOAD_DOCUMENT + from app.enums import NotificationType, ServicePermissionType notify_type_text = notify_type if notify_type == NotificationType.SMS: notify_type_text = "text message" - elif notify_type == UPLOAD_DOCUMENT: + elif notify_type == ServicePermissionType.UPLOAD_DOCUMENT: notify_type_text = "document" return "{}{}".format(notify_type_text, "s" if plural else "")