mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
Add an endpoint to delete a contact list
This was one of things we de-scoped when we first shipped this feature. In order to safely delete a list, we first need to make sure any jobs aren’t referencing it.
This commit is contained in:
@@ -29,6 +29,7 @@ from app.dao.fact_notification_status_dao import (
|
||||
fetch_stats_for_all_services_by_date_range, fetch_monthly_template_usage_for_service
|
||||
)
|
||||
from app.dao.inbound_numbers_dao import dao_allocate_number_for_service
|
||||
from app.dao.jobs_dao import dao_unlink_jobs_from_contact_list_id
|
||||
from app.dao.organisation_dao import dao_get_organisation_by_service_id
|
||||
from app.dao.returned_letters_dao import (
|
||||
fetch_most_recent_returned_letter,
|
||||
@@ -36,8 +37,12 @@ from app.dao.returned_letters_dao import (
|
||||
fetch_returned_letter_summary,
|
||||
fetch_returned_letters,
|
||||
)
|
||||
from app.dao.service_contact_list_dao import dao_get_contact_lists, save_service_contact_list, \
|
||||
dao_get_contact_list_by_id
|
||||
from app.dao.service_contact_list_dao import (
|
||||
dao_get_contact_lists,
|
||||
save_service_contact_list,
|
||||
dao_get_contact_list_by_id,
|
||||
dao_delete_contact_list,
|
||||
)
|
||||
from app.dao.service_data_retention_dao import (
|
||||
fetch_service_data_retention,
|
||||
fetch_service_data_retention_by_id,
|
||||
@@ -1034,6 +1039,18 @@ def get_contact_list_by_id(service_id, contact_list_id):
|
||||
return jsonify(contact_list.serialize())
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/contact-list/<uuid:contact_list_id>', methods=['DELETE'])
|
||||
def delete_contact_list_by_id(service_id, contact_list_id):
|
||||
contact_list = dao_get_contact_list_by_id(
|
||||
service_id=service_id,
|
||||
contact_list_id=contact_list_id,
|
||||
)
|
||||
dao_unlink_jobs_from_contact_list_id(contact_list.id)
|
||||
dao_delete_contact_list(contact_list)
|
||||
|
||||
return '', 204
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/contact-list', methods=['POST'])
|
||||
def create_contact_list(service_id):
|
||||
service_contact_list = validate(request.get_json(), create_service_contact_list_schema)
|
||||
|
||||
Reference in New Issue
Block a user