Refactor code for dao_fetch_servies_by_sms_sender to use inbound_numbers

This will need to be refactored after the deployment of api and admin and after the update script for existing services using inbound numbers has been executed.
This commit is contained in:
Ken Tsang
2017-08-16 12:27:42 +01:00
parent ce962380e3
commit c36423aac6
5 changed files with 113 additions and 22 deletions

View File

@@ -21,8 +21,11 @@ from app.models import (
InboundSms,
InboundNumber,
Organisation,
ServiceInboundApi
)
EMAIL_TYPE,
SMS_TYPE,
INBOUND_SMS_TYPE,
KEY_TYPE_NORMAL,
ServiceInboundApi)
from app.dao.users_dao import save_model_user
from app.dao.notifications_dao import dao_create_notification, dao_created_scheduled_notification
from app.dao.templates_dao import dao_create_template
@@ -57,6 +60,7 @@ def create_service(
sms_sender='testing',
research_mode=False,
active=True,
do_create_inbound_number=True,
):
service = Service(
name=service_name,
@@ -66,6 +70,10 @@ def create_service(
created_by=user or create_user(),
sms_sender=sms_sender,
)
if do_create_inbound_number and INBOUND_SMS_TYPE in service_permissions:
create_inbound_number(number=sms_sender, service_id=service.id)
dao_create_service(service, service.created_by, service_id, service_permissions=service_permissions)
service.active = active