Add page to change organisation type

If a user picks the wrong thing, we should be able to override it when
they go live.
This commit is contained in:
Chris Hill-Scott
2017-10-05 12:06:40 +01:00
parent 8cc8a0bf05
commit d438109630
5 changed files with 133 additions and 12 deletions

View File

@@ -141,6 +141,18 @@ def sms_code():
message='Code not found')])
def organisation_type():
return RadioField(
'Who runs this service?',
choices=[
('central', 'Central government'),
('local', 'Local government'),
('nhs', 'NHS'),
],
validators=[DataRequired()],
)
class LoginForm(Form):
email_address = StringField('Email address', validators=[
Length(min=5, max=255),
@@ -227,15 +239,11 @@ class CreateServiceForm(Form):
validators=[
DataRequired(message='Cant be empty')
])
organisation_type = RadioField(
'Who runs this service?',
choices=[
('central', 'Central government'),
('local', 'Local government'),
('nhs', 'NHS'),
],
validators=[DataRequired()],
)
organisation_type = organisation_type()
class OrganisationTypeForm(Form):
organisation_type = organisation_type()
class ConfirmPasswordForm(Form):

View File

@@ -34,6 +34,7 @@ from app.main.forms import (
LetterBranding,
ServiceInboundApiForm,
InternationalSMSForm,
OrganisationTypeForm,
)
from app import user_api_client, current_service, organisations_client, inbound_number_client
from notifications_utils.formatters import formatted_list
@@ -574,6 +575,28 @@ def service_set_letter_contact_block(service_id):
)
@main.route("/services/<service_id>/service-settings/set-organisation-type", methods=['GET', 'POST'])
@login_required
@user_has_permissions(admin_override=True)
def set_organisation_type(service_id):
form = OrganisationTypeForm(organisation_type=current_service.get('organisation_type'))
if form.validate_on_submit():
service_api_client.update_service(
service_id,
organisation_type=form.organisation_type.data,
)
return redirect(url_for('.service_settings', service_id=service_id))
form.organisation_type.data = current_service.get('organisation_type')
return render_template(
'views/service-settings/set-organisation-type.html',
form=form,
)
@main.route("/services/<service_id>/service-settings/set-branding-and-org", methods=['GET', 'POST'])
@login_required
@user_has_permissions(admin_override=True)

View File

@@ -193,7 +193,7 @@
{{ optional_text_field(
(current_service.organisation_type or '')|title
) }}
{{ text_field() }}
{{ edit_field('Change', url_for('.set_organisation_type', service_id=current_service.id)) }}
{% endcall %}
{% call row() %}
{{ text_field('Free text message allowance')}}

View File

@@ -0,0 +1,22 @@
{% extends "withnav_template.html" %}
{% from "components/radios.html" import radios, branding_radios %}
{% from "components/page-footer.html" import page_footer %}
{% block service_page_title %}
Set branding and organisation
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Set organisation type</h1>
<form method="post">
{{ radios(form.organisation_type) }}
{{ page_footer(
'Save',
back_link=url_for('.service_settings', service_id=current_service.id),
back_link_text='Back to settings'
) }}
</form>
</div>
{% endblock %}