mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Merge pull request #1234 from alphagov/letter-branding
Add platform admin setting for letter branding
This commit is contained in:
@@ -538,6 +538,20 @@ class ServiceBrandingOrg(Form):
|
||||
)
|
||||
|
||||
|
||||
class LetterBranding(Form):
|
||||
|
||||
def __init__(self, choices=[], *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.dvla_org_id.choices = choices
|
||||
|
||||
dvla_org_id = RadioField(
|
||||
'Which logo should this service’s letter have?',
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class Whitelist(Form):
|
||||
|
||||
def populate(self, email_addresses, phone_numbers):
|
||||
|
||||
@@ -26,7 +26,8 @@ from app.main.forms import (
|
||||
ServiceReplyToEmailFrom,
|
||||
ServiceSmsSender,
|
||||
ServiceLetterContactBlock,
|
||||
ServiceBrandingOrg
|
||||
ServiceBrandingOrg,
|
||||
LetterBranding,
|
||||
)
|
||||
from app import user_api_client, current_service, organisations_client
|
||||
|
||||
@@ -35,13 +36,17 @@ from app import user_api_client, current_service, organisations_client
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_settings(service_id):
|
||||
letter_branding_organisations = organisations_client.get_letter_organisations()
|
||||
if current_service['organisation']:
|
||||
organisation = organisations_client.get_organisation(current_service['organisation'])['organisation']
|
||||
else:
|
||||
organisation = None
|
||||
return render_template(
|
||||
'views/service-settings.html',
|
||||
organisation=organisation
|
||||
organisation=organisation,
|
||||
letter_branding=letter_branding_organisations.get(
|
||||
current_service.get('dvla_org_id', '001')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -314,6 +319,28 @@ def service_set_branding_and_org(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/service-settings/set-letter-branding", methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@user_has_permissions(admin_override=True)
|
||||
def set_letter_branding(service_id):
|
||||
|
||||
form = LetterBranding(choices=organisations_client.get_letter_organisations().items())
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service(
|
||||
service_id,
|
||||
dvla_organisation=form.dvla_org_id.data
|
||||
)
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
form.dvla_org_id.data = current_service.get('dvla_organisation', '001')
|
||||
|
||||
return render_template(
|
||||
'views/service-settings/set-letter-branding.html',
|
||||
form=form,
|
||||
)
|
||||
|
||||
|
||||
def get_branding_as_value_and_label(organisations):
|
||||
return [
|
||||
(organisation['id'], organisation['name'])
|
||||
|
||||
Reference in New Issue
Block a user