mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Refactored to use service_id to set flag
This commit is contained in:
@@ -26,8 +26,8 @@ def dao_set_inbound_number_to_service(service_id, inbound_number):
|
|||||||
|
|
||||||
|
|
||||||
@transactional
|
@transactional
|
||||||
def dao_set_inbound_number_active_flag(inbound_number_id, active):
|
def dao_set_inbound_number_active_flag(service_id, active):
|
||||||
inbound_number = InboundNumber.query.filter(InboundNumber.id == inbound_number_id).first()
|
inbound_number = InboundNumber.query.filter(InboundNumber.service_id == service_id).first()
|
||||||
inbound_number.active = active
|
inbound_number.active = active
|
||||||
|
|
||||||
db.session.add(inbound_number)
|
db.session.add(inbound_number)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def post_allocate_inbound_number(service_id):
|
|||||||
|
|
||||||
if inbound_number:
|
if inbound_number:
|
||||||
if not inbound_number.active:
|
if not inbound_number.active:
|
||||||
dao_set_inbound_number_active_flag(inbound_number.id, active=True)
|
dao_set_inbound_number_active_flag(service_id, active=True)
|
||||||
return '', 204
|
return '', 204
|
||||||
else:
|
else:
|
||||||
return '', 200
|
return '', 200
|
||||||
@@ -47,7 +47,7 @@ def post_allocate_inbound_number(service_id):
|
|||||||
raise InvalidRequest('No available inbound numbers', status_code=400)
|
raise InvalidRequest('No available inbound numbers', status_code=400)
|
||||||
|
|
||||||
|
|
||||||
@inbound_number_blueprint.route('/<uuid:inbound_number_id>/off', methods=['POST'])
|
@inbound_number_blueprint.route('/service/<uuid:service_id>/off', methods=['POST'])
|
||||||
def post_set_inbound_number_off(inbound_number_id):
|
def post_set_inbound_number_off(service_id):
|
||||||
dao_set_inbound_number_active_flag(inbound_number_id, active=False)
|
dao_set_inbound_number_active_flag(service_id, active=False)
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def test_set_inbound_number_active_flag(notify_db, notify_db_session, sample_ser
|
|||||||
inbound_number = create_inbound_number(number='1')
|
inbound_number = create_inbound_number(number='1')
|
||||||
dao_set_inbound_number_to_service(sample_service.id, inbound_number)
|
dao_set_inbound_number_to_service(sample_service.id, inbound_number)
|
||||||
|
|
||||||
dao_set_inbound_number_active_flag(inbound_number.id, active=active)
|
dao_set_inbound_number_active_flag(sample_service.id, active=active)
|
||||||
|
|
||||||
inbound_number = dao_get_inbound_number_for_service(sample_service.id)
|
inbound_number = dao_get_inbound_number_for_service(sample_service.id)
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ def test_rest_set_inbound_number_active_flag_off(
|
|||||||
admin_request.post(
|
admin_request.post(
|
||||||
'inbound_number.post_set_inbound_number_off',
|
'inbound_number.post_set_inbound_number_off',
|
||||||
_expected_status=204,
|
_expected_status=204,
|
||||||
inbound_number_id=inbound_number.id
|
service_id=service.id
|
||||||
)
|
)
|
||||||
|
|
||||||
inbound_number_from_db = dao_get_inbound_number_for_service(service.id)
|
inbound_number_from_db = dao_get_inbound_number_for_service(service.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user