Merge pull request #1328 from alphagov/international-default

Make international text messaging on by default for new services
This commit is contained in:
Chris Hill-Scott
2017-10-23 14:03:16 +01:00
committed by GitHub
6 changed files with 90 additions and 33 deletions

View File

@@ -35,11 +35,19 @@ from app.models import (
JobStatistics,
SMS_TYPE,
EMAIL_TYPE,
ServiceSmsSender)
INTERNATIONAL_SMS_TYPE,
ServiceSmsSender,
)
from app.service.statistics import format_monthly_template_notification_stats
from app.statsd_decorators import statsd
from app.utils import get_london_month_from_utc_column, get_london_midnight_in_utc
DEFAULT_SERVICE_PERMISSIONS = [
SMS_TYPE,
EMAIL_TYPE,
INTERNATIONAL_SMS_TYPE,
]
def dao_fetch_all_services(only_active=False):
query = Service.query.order_by(
@@ -146,13 +154,16 @@ def dao_fetch_service_by_id_and_user(service_id, user_id):
@transactional
@version_class(Service)
def dao_create_service(service, user, service_id=None, service_permissions=[SMS_TYPE, EMAIL_TYPE]):
def dao_create_service(service, user, service_id=None, service_permissions=None):
# the default property does not appear to work when there is a difference between the sqlalchemy schema and the
# db schema (ie: during a migration), so we have to set sms_sender manually here. After the GOVUK sms_sender
# migration is completed, this code should be able to be removed.
if not service.sms_sender:
service.sms_sender = current_app.config['FROM_NUMBER']
if service_permissions is None:
service_permissions = DEFAULT_SERVICE_PERMISSIONS
from app.dao.permissions_dao import permission_dao
service.users.append(user)
permission_dao.add_default_service_permissions_for_user(user, service)