mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-04 08:01:34 -04:00
Assign email branding based on user’s email domain
When a user creates a service we can take a pretty good guess at what organisation they’re from. For many organisations, especially local councils, GOV.UK branding is not appropriate for their service. But right now every service: - gets created with GOV.UK branding - has to ask us to change it, even if they’ve already done so for other services they run This commit starts using the `domain` field on the email branding table to lookup what email branding to assign to a service automatically, where we’re sure there’s a sensible default.
This commit is contained in:
@@ -5,6 +5,7 @@ from werkzeug.exceptions import abort
|
||||
|
||||
from app import (
|
||||
billing_api_client,
|
||||
email_branding_client,
|
||||
invite_api_client,
|
||||
service_api_client,
|
||||
user_api_client,
|
||||
@@ -12,7 +13,7 @@ from app import (
|
||||
from app.main import main
|
||||
from app.main.forms import CreateServiceForm
|
||||
from app.notify_client.models import InvitedUser
|
||||
from app.utils import email_safe, is_gov_user
|
||||
from app.utils import AgreementInfo, email_safe, is_gov_user
|
||||
|
||||
|
||||
def _add_invited_user_to_service(invited_user):
|
||||
@@ -27,6 +28,9 @@ def _add_invited_user_to_service(invited_user):
|
||||
|
||||
def _create_service(service_name, organisation_type, email_from, form):
|
||||
free_sms_fragment_limit = current_app.config['DEFAULT_FREE_SMS_FRAGMENT_LIMITS'].get(organisation_type)
|
||||
email_branding = email_branding_client.get_email_branding_id_for_domain(
|
||||
AgreementInfo.from_current_user().canonical_domain
|
||||
)
|
||||
try:
|
||||
service_id = service_api_client.create_service(
|
||||
service_name=service_name,
|
||||
@@ -38,6 +42,9 @@ def _create_service(service_name, organisation_type, email_from, form):
|
||||
)
|
||||
session['service_id'] = service_id
|
||||
|
||||
if email_branding:
|
||||
service_api_client.update_service(service_id, email_branding=email_branding)
|
||||
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit(service_id, free_sms_fragment_limit)
|
||||
|
||||
return service_id, None
|
||||
|
||||
Reference in New Issue
Block a user