diff --git a/app/__init__.py b/app/__init__.py index e6c8f47f8..429f1ff5b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -288,6 +288,8 @@ def load_user(user_id): def load_service_before_request(): + if '/static/' in request.url: + return service_id = request.view_args.get('service_id', session.get('service_id')) if request.view_args \ else session.get('service_id') from flask.globals import _request_ctx_stack @@ -296,6 +298,7 @@ def load_service_before_request(): _request_ctx_stack.top, 'service', service_api_client.get_service(service_id)['data'] if service_id else None) + print('before_request', request.url) def save_service_after_request(response): diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 30d69a225..e5b341533 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -276,17 +276,19 @@ def service_set_branding_and_org(service_id): form = ServiceBrandingOrg(branding_type=current_service.get('branding')) # dynamically create org choices, including the null option - form.organisation.choices = [('', 'None')] + get_branding_as_value_and_label(organisations) - form.organisation.data = current_service['organisation'] or '' + form.organisation.choices = [('nil', 'None')] + get_branding_as_value_and_label(organisations) if form.validate_on_submit(): - organisation = None if form.organisation.data == '' else form.organisation.data + organisation = None if form.organisation.data == 'nil' else form.organisation.data service_api_client.update_service( service_id, branding=form.branding_type.data, - organisation=organisation + organisation_id=organisation ) return redirect(url_for('.service_settings', service_id=service_id)) + + # only set form.organisation.data on GET (to select correct initial radio button) + form.organisation.data = current_service['organisation'] or 'nil' return render_template( 'views/service-settings/set-branding-and-org.html', form=form, diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 718ef3946..65ad34a50 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -90,7 +90,9 @@ class ServiceAPIClient(NotificationsAPIClient): 'email_from', 'reply_to_email_address', 'sms_sender', - 'created_by' + 'created_by', + 'branding', + 'organisation_id' } if disallowed_attributes: raise TypeError('Not allowed to update service attributes: {}'.format(