mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 08:39:49 -04:00
Change service billing details
View page that lets you change service billing details and update details on form submission.
This commit is contained in:
@@ -1686,6 +1686,13 @@ class EditServiceNotesForm(StripWhitespaceForm):
|
|||||||
notes = TextAreaField(validators=[])
|
notes = TextAreaField(validators=[])
|
||||||
|
|
||||||
|
|
||||||
|
class ServiceBillingDetailsForm(StripWhitespaceForm):
|
||||||
|
billing_contact_email_address = GovukTextInputField('Billing contact email address')
|
||||||
|
billing_contact_name = GovukTextInputField('Billing contact name')
|
||||||
|
billing_reference = GovukTextInputField('Billing reference')
|
||||||
|
purchase_order_number = GovukTextInputField('Purchase order number')
|
||||||
|
|
||||||
|
|
||||||
class ServiceLetterContactBlockForm(StripWhitespaceForm):
|
class ServiceLetterContactBlockForm(StripWhitespaceForm):
|
||||||
letter_contact_block = TextAreaField(
|
letter_contact_block = TextAreaField(
|
||||||
validators=[
|
validators=[
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ from app.main.forms import (
|
|||||||
RateLimit,
|
RateLimit,
|
||||||
RenameServiceForm,
|
RenameServiceForm,
|
||||||
SearchByNameForm,
|
SearchByNameForm,
|
||||||
|
ServiceBillingDetailsForm,
|
||||||
ServiceContactDetailsForm,
|
ServiceContactDetailsForm,
|
||||||
ServiceDataRetentionEditForm,
|
ServiceDataRetentionEditForm,
|
||||||
ServiceDataRetentionForm,
|
ServiceDataRetentionForm,
|
||||||
@@ -1213,7 +1214,26 @@ def edit_service_notes(service_id):
|
|||||||
@main.route("/services/<uuid:service_id>/edit-billing-details", methods=['GET', 'POST'])
|
@main.route("/services/<uuid:service_id>/edit-billing-details", methods=['GET', 'POST'])
|
||||||
@user_is_platform_admin
|
@user_is_platform_admin
|
||||||
def edit_service_billing_details(service_id):
|
def edit_service_billing_details(service_id):
|
||||||
pass
|
form = ServiceBillingDetailsForm(
|
||||||
|
billing_contact_email_address=current_service.billing_contact_email_address,
|
||||||
|
billing_contact_name=current_service.billing_contact_name,
|
||||||
|
billing_reference=current_service.billing_reference,
|
||||||
|
purchase_order_number=current_service.purchase_order_number
|
||||||
|
)
|
||||||
|
|
||||||
|
if form.validate_on_submit():
|
||||||
|
current_service.update(
|
||||||
|
billing_contact_email_address=form.billing_contact_email_address.data,
|
||||||
|
billing_contact_name=form.billing_contact_name.data,
|
||||||
|
billing_reference=form.billing_reference.data,
|
||||||
|
purchase_order_number=form.purchase_order_number.data
|
||||||
|
)
|
||||||
|
return redirect(url_for('.service_settings', service_id=service_id))
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'views/service-settings/edit-service-billing-details.html',
|
||||||
|
form=form,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_branding_as_value_and_label(email_branding):
|
def get_branding_as_value_and_label(email_branding):
|
||||||
|
|||||||
@@ -80,10 +80,13 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
data = _attach_current_user(kwargs)
|
data = _attach_current_user(kwargs)
|
||||||
disallowed_attributes = set(data.keys()) - {
|
disallowed_attributes = set(data.keys()) - {
|
||||||
'active',
|
'active',
|
||||||
|
'billing_contact_email_address',
|
||||||
|
'billing_contact_name',
|
||||||
|
'billing_reference',
|
||||||
'consent_to_research',
|
'consent_to_research',
|
||||||
'contact_link',
|
'contact_link',
|
||||||
'count_as_live',
|
|
||||||
'created_by',
|
'created_by',
|
||||||
|
'count_as_live',
|
||||||
'email_branding',
|
'email_branding',
|
||||||
'email_from',
|
'email_from',
|
||||||
'free_sms_fragment_limit',
|
'free_sms_fragment_limit',
|
||||||
@@ -97,6 +100,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
'organisation_type',
|
'organisation_type',
|
||||||
'permissions',
|
'permissions',
|
||||||
'prefix_sms',
|
'prefix_sms',
|
||||||
|
'purchase_order_number',
|
||||||
'rate_limit',
|
'rate_limit',
|
||||||
'reply_to_email_address',
|
'reply_to_email_address',
|
||||||
'research_mode',
|
'research_mode',
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
{% extends "withnav_template.html" %}
|
||||||
|
{% from "components/page-header.html" import page_header %}
|
||||||
|
{% from "components/page-footer.html" import page_footer %}
|
||||||
|
{% from "components/form.html" import form_wrapper %}
|
||||||
|
|
||||||
|
{% block service_page_title %}
|
||||||
|
Change service billing details
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
|
{{ page_header(
|
||||||
|
'Change service billing details',
|
||||||
|
back_link=url_for('main.service_settings', service_id=current_service.id)
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{% call form_wrapper() %}
|
||||||
|
{{ form.billing_contact_name }}
|
||||||
|
{{ form.billing_contact_email_address }}
|
||||||
|
{{ form.billing_reference }}
|
||||||
|
{{ form.purchase_order_number }}
|
||||||
|
{{ page_footer('Save') }}
|
||||||
|
{% endcall %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -5300,3 +5300,54 @@ def test_service_settings_links_to_edit_service_billing_details_page_for_platfor
|
|||||||
))
|
))
|
||||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
assert len(page.find_all('a', attrs={'href': '/services/{}/edit-billing-details'.format(SERVICE_ONE_ID)})) == 1
|
assert len(page.find_all('a', attrs={'href': '/services/{}/edit-billing-details'.format(SERVICE_ONE_ID)})) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_view_edit_service_billing_details(
|
||||||
|
platform_admin_client,
|
||||||
|
service_one,
|
||||||
|
|
||||||
|
):
|
||||||
|
response = platform_admin_client.get(url_for('main.edit_service_billing_details', service_id=SERVICE_ONE_ID))
|
||||||
|
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||||
|
assert page.select_one('h1').text == "Change service billing details"
|
||||||
|
labels = page.find_all('label', class_="form-label")
|
||||||
|
labels_list = [
|
||||||
|
'Billing contact email address', 'Billing contact name', 'Billing reference', 'Purchase order number'
|
||||||
|
]
|
||||||
|
for label in labels:
|
||||||
|
assert label.text.strip() in labels_list
|
||||||
|
textbox_names = page.find_all('input', class_='govuk-input govuk-!-width-two-thirds')
|
||||||
|
names_list = ['billing_contact_email_address', 'billing_contact_name', 'billing_reference', 'purchase_order_number']
|
||||||
|
|
||||||
|
for name in textbox_names:
|
||||||
|
assert name.attrs["name"] in names_list
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_service_billing_details(
|
||||||
|
platform_admin_client,
|
||||||
|
service_one,
|
||||||
|
mock_update_service
|
||||||
|
):
|
||||||
|
response = platform_admin_client.post(
|
||||||
|
url_for(
|
||||||
|
'main.edit_service_billing_details',
|
||||||
|
service_id=SERVICE_ONE_ID,
|
||||||
|
),
|
||||||
|
data={
|
||||||
|
'billing_contact_email_address': 'accounts@fluff.gov.uk',
|
||||||
|
'billing_contact_name': 'Flannellette von Fluff',
|
||||||
|
'billing_reference': '',
|
||||||
|
'purchase_order_number': 'PO1234'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
assert response.status_code == 302
|
||||||
|
settings_url = url_for(
|
||||||
|
'main.service_settings', service_id=SERVICE_ONE_ID, _external=True)
|
||||||
|
assert response.location == settings_url
|
||||||
|
mock_update_service.assert_called_with(
|
||||||
|
SERVICE_ONE_ID,
|
||||||
|
billing_contact_email_address='accounts@fluff.gov.uk',
|
||||||
|
billing_contact_name='Flannellette von Fluff',
|
||||||
|
billing_reference='',
|
||||||
|
purchase_order_number='PO1234'
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user