mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Merge pull request #3038 from alphagov/add-more-info-when-creating-org
Require more information when creating organisations
This commit is contained in:
@@ -594,6 +594,17 @@ class OrganisationTypeForm(StripWhitespaceForm):
|
||||
organisation_type = organisation_type()
|
||||
|
||||
|
||||
class NewOrganisationForm(
|
||||
RenameOrganisationForm,
|
||||
OrganisationOrganisationTypeForm,
|
||||
OrganisationCrownStatusForm,
|
||||
):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
# Don’t offer the ‘not sure’ choice
|
||||
self.crown_status.choices = self.crown_status.choices[:-1]
|
||||
|
||||
|
||||
class FreeSMSAllowance(StripWhitespaceForm):
|
||||
free_sms_allowance = IntegerField(
|
||||
'Numbers of text message fragments per year',
|
||||
@@ -1039,11 +1050,6 @@ class PDFUploadForm(StripWhitespaceForm):
|
||||
)
|
||||
|
||||
|
||||
class CreateOrUpdateOrganisation(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name', validators=[DataRequired()])
|
||||
|
||||
|
||||
class EmailFieldInWhitelist(EmailField, StripWhitespaceStringField):
|
||||
pass
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ from app import (
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
ConfirmPasswordForm,
|
||||
CreateOrUpdateOrganisation,
|
||||
GoLiveNotesForm,
|
||||
InviteOrgUserForm,
|
||||
NewOrganisationForm,
|
||||
OrganisationAgreementSignedForm,
|
||||
OrganisationCrownStatusForm,
|
||||
OrganisationDomainsForm,
|
||||
@@ -31,7 +31,7 @@ from app.main.forms import (
|
||||
SetLetterBranding,
|
||||
)
|
||||
from app.main.views.service_settings import get_branding_as_value_and_label
|
||||
from app.models.organisation import Organisations
|
||||
from app.models.organisation import Organisation, Organisations
|
||||
from app.models.user import InvitedOrgUser, User
|
||||
from app.utils import user_has_permissions, user_is_platform_admin
|
||||
|
||||
@@ -49,14 +49,13 @@ def organisations():
|
||||
@main.route("/organisations/add", methods=['GET', 'POST'])
|
||||
@user_is_platform_admin
|
||||
def add_organisation():
|
||||
form = CreateOrUpdateOrganisation()
|
||||
form = NewOrganisationForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
organisations_client.create_organisation(
|
||||
name=form.name.data,
|
||||
)
|
||||
|
||||
return redirect(url_for('.organisations'))
|
||||
return redirect(url_for(
|
||||
'.organisation_settings',
|
||||
org_id=Organisation.create_from_form(form).id,
|
||||
))
|
||||
|
||||
return render_template(
|
||||
'views/organisations/add-organisation.html',
|
||||
|
||||
@@ -38,6 +38,27 @@ class Organisation(JSONModel):
|
||||
def from_service(cls, service_id):
|
||||
return cls(organisations_client.get_service_organisation(service_id))
|
||||
|
||||
@classmethod
|
||||
def create_from_form(cls, form):
|
||||
return cls.create(
|
||||
name=form.name.data,
|
||||
crown={
|
||||
'crown': True,
|
||||
'non-crown': False,
|
||||
'unknown': None,
|
||||
}.get(form.crown_status.data),
|
||||
organisation_type=form.organisation_type.data,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def create(cls, name, crown, organisation_type, agreement_signed=False):
|
||||
return cls(organisations_client.create_organisation(
|
||||
name=name,
|
||||
crown=crown,
|
||||
organisation_type=organisation_type,
|
||||
agreement_signed=agreement_signed,
|
||||
))
|
||||
|
||||
def __init__(self, _dict):
|
||||
|
||||
super().__init__(_dict)
|
||||
|
||||
@@ -80,7 +80,6 @@ class HeaderNavigation(Navigation):
|
||||
'user_profile_disable_platform_admin_view',
|
||||
},
|
||||
'platform-admin': {
|
||||
'add_organisation',
|
||||
'archive_user',
|
||||
'clear_cache',
|
||||
'create_email_branding',
|
||||
@@ -120,6 +119,7 @@ class HeaderNavigation(Navigation):
|
||||
'accept_org_invite',
|
||||
'action_blocked',
|
||||
'add_data_retention',
|
||||
'add_organisation',
|
||||
'add_service',
|
||||
'add_service_template',
|
||||
'agreement',
|
||||
|
||||
@@ -32,11 +32,16 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
||||
raise error
|
||||
|
||||
@cache.delete('organisations')
|
||||
def create_organisation(self, name):
|
||||
data = {
|
||||
"name": name
|
||||
}
|
||||
return self.post(url="/organisations", data=data)
|
||||
def create_organisation(self, name, crown, organisation_type, agreement_signed):
|
||||
return self.post(
|
||||
url="/organisations",
|
||||
data={
|
||||
"name": name,
|
||||
"crown": crown,
|
||||
"organisation_type": organisation_type,
|
||||
"agreement_signed": agreement_signed,
|
||||
}
|
||||
)
|
||||
|
||||
@cache.delete('domains')
|
||||
@cache.delete('organisations')
|
||||
|
||||
@@ -1,27 +1,39 @@
|
||||
{% extends "views/platform-admin/_base_template.html" %}
|
||||
{% extends "withoutnav_template.html" %}
|
||||
{% from "components/page-header.html" import page_header %}
|
||||
{% from "components/page-footer.html" import page_footer %}
|
||||
{% from "components/textbox.html" import textbox %}
|
||||
{% from "components/radios.html" import radios %}
|
||||
{% from "components/form.html" import form_wrapper %}
|
||||
|
||||
{% block per_page_title %}
|
||||
Create an organisation
|
||||
New organisation
|
||||
{% endblock %}
|
||||
|
||||
{% block org_page_title %}
|
||||
Create an organisation
|
||||
{% endblock %}
|
||||
{% block fullwidth_content %}
|
||||
<div id="content">
|
||||
<div class="navigation-service">
|
||||
<div class="navigation-service-name">
|
||||
<a href="{{ url_for('.organisations') }}">All organisations</a>
|
||||
</div>
|
||||
<a href="{{ url_for('main.choose_account') }}" class="navigation-service-switch">Switch service</a>
|
||||
</div>
|
||||
|
||||
{% block platform_admin_content %}
|
||||
|
||||
{{ page_header(
|
||||
'New organisation',
|
||||
back_link=url_for('.organisations')
|
||||
) }}
|
||||
|
||||
{% call form_wrapper() %}
|
||||
{{textbox(form.name)}}
|
||||
{{ page_footer('Save') }}
|
||||
{% endcall %}
|
||||
<main role="main">
|
||||
<div class="grid-row">
|
||||
<div class="column-one-quarter">
|
||||
|
||||
</div>
|
||||
<div class="column-three-quarters">
|
||||
{{ page_header('New organisation') }}
|
||||
{% call form_wrapper() %}
|
||||
{{textbox(form.name)}}
|
||||
{{radios(form.organisation_type)}}
|
||||
{{radios(form.crown_status)}}
|
||||
{{ page_footer('Save') }}
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user