mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Collect organisation type
So that we can default services to their appropriate text allowance, we need to find out what sector they're in. So let's start collecting that from teams as they create new services. I think Central/Local/NHS are the right options, but these can be easily changed if not.
This commit is contained in:
@@ -213,7 +213,7 @@ class TextNotReceivedForm(Form):
|
||||
mobile_number = international_phone_number()
|
||||
|
||||
|
||||
class ServiceNameForm(Form):
|
||||
class RenameServiceForm(Form):
|
||||
name = StringField(
|
||||
u'Service name',
|
||||
validators=[
|
||||
@@ -221,6 +221,23 @@ class ServiceNameForm(Form):
|
||||
])
|
||||
|
||||
|
||||
class CreateServiceForm(Form):
|
||||
name = StringField(
|
||||
u'What’s your service called?',
|
||||
validators=[
|
||||
DataRequired(message='Can’t be empty')
|
||||
])
|
||||
organisation_type = RadioField(
|
||||
'Who runs this service?',
|
||||
choices=[
|
||||
('central', 'Central government'),
|
||||
('local', 'Local government'),
|
||||
('nhs', 'NHS'),
|
||||
],
|
||||
validators=[DataRequired()],
|
||||
)
|
||||
|
||||
|
||||
class ConfirmPasswordForm(Form):
|
||||
def __init__(self, validate_password_func, *args, **kwargs):
|
||||
self.validate_password_func = validate_password_func
|
||||
|
||||
@@ -14,7 +14,7 @@ from notifications_python_client.errors import HTTPError
|
||||
from werkzeug.exceptions import abort
|
||||
|
||||
from app.main import main
|
||||
from app.main.forms import ServiceNameForm
|
||||
from app.main.forms import CreateServiceForm
|
||||
from app.notify_client.models import InvitedUser
|
||||
|
||||
from app import (
|
||||
@@ -39,13 +39,16 @@ def _add_invited_user_to_service(invited_user):
|
||||
return service_id
|
||||
|
||||
|
||||
def _create_service(service_name, email_from, form):
|
||||
def _create_service(service_name, organisation_type, email_from, form):
|
||||
try:
|
||||
service_id = service_api_client.create_service(service_name=service_name,
|
||||
message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
|
||||
restricted=True,
|
||||
user_id=session['user_id'],
|
||||
email_from=email_from)
|
||||
service_id = service_api_client.create_service(
|
||||
service_name=service_name,
|
||||
organisation_type=organisation_type,
|
||||
message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
|
||||
restricted=True,
|
||||
user_id=session['user_id'],
|
||||
email_from=email_from,
|
||||
)
|
||||
session['service_id'] = service_id
|
||||
return service_id, None
|
||||
except HTTPError as e:
|
||||
@@ -78,14 +81,14 @@ def add_service():
|
||||
if not is_gov_user(current_user.email_address):
|
||||
abort(403)
|
||||
|
||||
form = ServiceNameForm()
|
||||
heading = 'Which service do you want to set up notifications for?'
|
||||
form = CreateServiceForm()
|
||||
heading = 'About your service'
|
||||
|
||||
if form.validate_on_submit():
|
||||
email_from = email_safe(form.name.data)
|
||||
service_name = form.name.data
|
||||
|
||||
service_id, error = _create_service(service_name, email_from, form)
|
||||
service_id, error = _create_service(service_name, form.organisation_type.data, email_from, form)
|
||||
if error:
|
||||
return render_template('views/add-service.html', form=form, heading=heading)
|
||||
if len(service_api_client.get_active_services({'user_id': session['user_id']}).get('data', [])) > 1:
|
||||
|
||||
@@ -25,7 +25,7 @@ from app.main import main
|
||||
from app.utils import user_has_permissions, email_safe, get_cdn_domain
|
||||
from app.main.forms import (
|
||||
ConfirmPasswordForm,
|
||||
ServiceNameForm,
|
||||
RenameServiceForm,
|
||||
RequestToGoLiveForm,
|
||||
ServiceReplyToEmailForm,
|
||||
ServiceSmsSender,
|
||||
@@ -100,7 +100,7 @@ def service_settings(service_id):
|
||||
@login_required
|
||||
@user_has_permissions('manage_settings', admin_override=True)
|
||||
def service_name_change(service_id):
|
||||
form = ServiceNameForm()
|
||||
form = RenameServiceForm()
|
||||
|
||||
if request.method == 'GET':
|
||||
form.name.data = current_service.get('name')
|
||||
|
||||
@@ -16,12 +16,21 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
self.service_id = application.config['ADMIN_CLIENT_USER_NAME']
|
||||
self.api_key = application.config['ADMIN_CLIENT_SECRET']
|
||||
|
||||
def create_service(self, service_name, message_limit, restricted, user_id, email_from):
|
||||
def create_service(
|
||||
self,
|
||||
service_name,
|
||||
organisation_type,
|
||||
message_limit,
|
||||
restricted,
|
||||
user_id,
|
||||
email_from,
|
||||
):
|
||||
"""
|
||||
Create a service and return the json.
|
||||
"""
|
||||
data = {
|
||||
"name": service_name,
|
||||
"organisation_type": organisation_type,
|
||||
"active": True,
|
||||
"message_limit": message_limit,
|
||||
"user_id": user_id,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% extends "withoutnav_template.html" %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
|
||||
@@ -12,13 +13,15 @@
|
||||
<div class="column-two-thirds">
|
||||
|
||||
<h1 class="heading-large">
|
||||
When people receive notifications, who should they be from?
|
||||
About your service
|
||||
</h1>
|
||||
|
||||
<form autocomplete="off" method="post">
|
||||
|
||||
{{ textbox(form.name, hint="You can change this later") }}
|
||||
|
||||
{{ radios(form.organisation_type) }}
|
||||
|
||||
{{ page_footer('Add service') }}
|
||||
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user