mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Cleaning up a lot of things, getting Enums used everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -633,7 +633,7 @@ def get_detailed_services(
|
||||
|
||||
@service_blueprint.route("/<uuid:service_id>/guest-list", methods=["GET"])
|
||||
def get_guest_list(service_id):
|
||||
from app.models import EMAIL_TYPE, MOBILE_TYPE
|
||||
from app.models import GuestListRecipientType
|
||||
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
|
||||
@@ -643,10 +643,10 @@ def get_guest_list(service_id):
|
||||
guest_list = dao_fetch_service_guest_list(service.id)
|
||||
return jsonify(
|
||||
email_addresses=[
|
||||
item.recipient for item in guest_list if item.recipient_type == EMAIL_TYPE
|
||||
item.recipient for item in guest_list if item.recipient_type == GuestListRecipientType.EMAIL
|
||||
],
|
||||
phone_numbers=[
|
||||
item.recipient for item in guest_list if item.recipient_type == MOBILE_TYPE
|
||||
item.recipient for item in guest_list if item.recipient_type == GuestListRecipientType.MOBILE
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -6,7 +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.models import EMAIL_TYPE, KEY_TYPE_NORMAL, PRIORITY, SMS_TYPE
|
||||
from app.models import KEY_TYPE_NORMAL, PRIORITY, NotificationType
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -94,10 +94,10 @@ def get_reply_to_text(notification_type, sender_id, service, template):
|
||||
reply_to = None
|
||||
if sender_id:
|
||||
try:
|
||||
if notification_type == EMAIL_TYPE:
|
||||
if notification_type == NotificationType.EMAIL:
|
||||
message = "Reply to email address not found"
|
||||
reply_to = dao_get_reply_to_by_id(service.id, sender_id).email_address
|
||||
elif notification_type == SMS_TYPE:
|
||||
elif notification_type == NotificationType.SMS:
|
||||
message = "SMS sender not found"
|
||||
reply_to = dao_get_service_sms_senders_by_id(
|
||||
service.id, sender_id
|
||||
|
||||
@@ -6,7 +6,7 @@ from app.dao.services_dao import (
|
||||
dao_fetch_service_by_id,
|
||||
)
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.models import EMAIL_TYPE, KEY_TYPE_NORMAL
|
||||
from app.models import KEY_TYPE_NORMAL, TemplateType
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -29,7 +29,7 @@ def send_notification_to_service_users(
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
recipient=user.email_address
|
||||
if template.template_type == EMAIL_TYPE
|
||||
if template.template_type == TemplateType.EMAIL
|
||||
else user.mobile_number,
|
||||
service=notify_service,
|
||||
personalisation=personalisation,
|
||||
|
||||
@@ -4,11 +4,10 @@ from notifications_utils.recipients import allowed_to_send_to
|
||||
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.models import (
|
||||
EMAIL_TYPE,
|
||||
KEY_TYPE_NORMAL,
|
||||
KEY_TYPE_TEAM,
|
||||
KEY_TYPE_TEST,
|
||||
MOBILE_TYPE,
|
||||
GuestListRecipientType,
|
||||
ServiceGuestList,
|
||||
)
|
||||
|
||||
@@ -21,8 +20,8 @@ def get_guest_list_objects(service_id, request_json):
|
||||
return [
|
||||
ServiceGuestList.from_string(service_id, type, recipient)
|
||||
for type, recipient in (
|
||||
get_recipients_from_request(request_json, "phone_numbers", MOBILE_TYPE)
|
||||
+ get_recipients_from_request(request_json, "email_addresses", EMAIL_TYPE)
|
||||
get_recipients_from_request(request_json, "phone_numbers", GuestListRecipientType.MOBILE)
|
||||
+ get_recipients_from_request(request_json, "email_addresses", GuestListRecipientType.EMAIL)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user