mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Don’t ask for organisation type when we know it
Every time someone adds a new service we ask them what kind of organisation they work for. We can look this up based on the user’s email address now. So we should only ask the question if: - we don’t know about the organisation - or we haven’t set what type of organisation it is (this shouldn’t be possible on productions because we’ve populated the column for all existing organisations and it’s impossible to add a new one without setting it
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from flask import current_app, redirect, render_template, session, url_for
|
||||
from flask_login import login_required
|
||||
from flask_login import current_user, login_required
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app import billing_api_client, service_api_client
|
||||
@@ -47,14 +47,21 @@ def _create_example_template(service_id):
|
||||
@login_required
|
||||
@user_is_gov_user
|
||||
def add_service():
|
||||
form = CreateServiceForm()
|
||||
form = CreateServiceForm(
|
||||
organisation_type=current_user.default_organisation.organisation_type
|
||||
)
|
||||
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, form.organisation_type.data, email_from, form)
|
||||
service_id, error = _create_service(
|
||||
service_name,
|
||||
current_user.default_organisation.organisation_type or 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:
|
||||
|
||||
Reference in New Issue
Block a user