mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 05:58:53 -04:00
Rename methods and variables in rest.py
To reflect the new name of this feature.
This commit is contained in:
@@ -562,36 +562,36 @@ def get_detailed_services(start_date, end_date, only_active=False, include_from_
|
|||||||
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['GET'])
|
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['GET'])
|
||||||
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['GET'])
|
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['GET'])
|
||||||
def get_whitelist(service_id):
|
def get_guest_list(service_id):
|
||||||
from app.models import (EMAIL_TYPE, MOBILE_TYPE)
|
from app.models import (EMAIL_TYPE, MOBILE_TYPE)
|
||||||
service = dao_fetch_service_by_id(service_id)
|
service = dao_fetch_service_by_id(service_id)
|
||||||
|
|
||||||
if not service:
|
if not service:
|
||||||
raise InvalidRequest("Service does not exist", status_code=404)
|
raise InvalidRequest("Service does not exist", status_code=404)
|
||||||
|
|
||||||
whitelist = dao_fetch_service_whitelist(service.id)
|
guest_list = dao_fetch_service_whitelist(service.id)
|
||||||
return jsonify(
|
return jsonify(
|
||||||
email_addresses=[item.recipient for item in whitelist
|
email_addresses=[item.recipient for item in guest_list
|
||||||
if item.recipient_type == EMAIL_TYPE],
|
if item.recipient_type == EMAIL_TYPE],
|
||||||
phone_numbers=[item.recipient for item in whitelist
|
phone_numbers=[item.recipient for item in guest_list
|
||||||
if item.recipient_type == MOBILE_TYPE]
|
if item.recipient_type == MOBILE_TYPE]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['PUT'])
|
@service_blueprint.route('/<uuid:service_id>/whitelist', methods=['PUT'])
|
||||||
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['PUT'])
|
@service_blueprint.route('/<uuid:service_id>/guest-list', methods=['PUT'])
|
||||||
def update_whitelist(service_id):
|
def update_guest_list(service_id):
|
||||||
# doesn't commit so if there are any errors, we preserve old values in db
|
# doesn't commit so if there are any errors, we preserve old values in db
|
||||||
dao_remove_service_whitelist(service_id)
|
dao_remove_service_whitelist(service_id)
|
||||||
try:
|
try:
|
||||||
whitelist_objs = get_whitelist_objects(service_id, request.get_json())
|
guest_list_objects = get_whitelist_objects(service_id, request.get_json())
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
current_app.logger.exception(e)
|
current_app.logger.exception(e)
|
||||||
dao_rollback()
|
dao_rollback()
|
||||||
msg = '{} is not a valid email address or phone number'.format(str(e))
|
msg = '{} is not a valid email address or phone number'.format(str(e))
|
||||||
raise InvalidRequest(msg, 400)
|
raise InvalidRequest(msg, 400)
|
||||||
else:
|
else:
|
||||||
dao_add_and_commit_whitelisted_contacts(whitelist_objs)
|
dao_add_and_commit_whitelisted_contacts(guest_list_objects)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user