mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-29 18:40:10 -04:00
Get organisations list from API rather than config
Hard coding the organisations means this information is duplicated between the admin and the API, and could get out of sync.
This commit is contained in:
@@ -83,11 +83,6 @@ class Config(object):
|
||||
r"assembly\.wales",
|
||||
]
|
||||
|
||||
LETTER_BRANDING = [
|
||||
('001', 'HM Government'),
|
||||
('500', 'Land Registry'),
|
||||
]
|
||||
|
||||
|
||||
class Development(Config):
|
||||
DEBUG = True
|
||||
|
||||
@@ -36,6 +36,7 @@ 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:
|
||||
@@ -43,9 +44,9 @@ def service_settings(service_id):
|
||||
return render_template(
|
||||
'views/service-settings.html',
|
||||
organisation=organisation,
|
||||
letter_branding=dict(
|
||||
current_app.config['LETTER_BRANDING']
|
||||
).get(current_service.get('dvla_org_id', '001'))
|
||||
letter_branding=letter_branding_organisations.get(
|
||||
current_service.get('dvla_org_id', '001')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -323,7 +324,7 @@ def service_set_branding_and_org(service_id):
|
||||
@user_has_permissions(admin_override=True)
|
||||
def set_letter_branding(service_id):
|
||||
|
||||
form = LetterBranding(choices=current_app.config['LETTER_BRANDING'])
|
||||
form = LetterBranding(choices=organisations_client.get_letter_organisations().items())
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service(
|
||||
|
||||
@@ -16,3 +16,6 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
|
||||
def get_organisations(self):
|
||||
return self.get(url='/organisation')['organisations']
|
||||
|
||||
def get_letter_organisations(self):
|
||||
return self.get(url='/dvla_organisations')
|
||||
|
||||
Reference in New Issue
Block a user