mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Merge pull request #2917 from alphagov/record-user-that-requested-to-go-live
Update service with the user that requested to go live.
This commit is contained in:
@@ -247,6 +247,8 @@ def submit_request_to_go_live(service_id):
|
||||
tags=current_service.request_to_go_live_tags,
|
||||
)
|
||||
|
||||
current_service.update(go_live_user=current_user.id)
|
||||
|
||||
flash('Thanks for your request to go live. We’ll get back to you within one working day.', 'default')
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ class Service(JSONModel):
|
||||
'volume_letter',
|
||||
'consent_to_research',
|
||||
'count_as_live',
|
||||
'go_live_user',
|
||||
'go_live_at'
|
||||
}
|
||||
|
||||
TEMPLATE_TYPES = (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
|
||||
|
||||
@@ -87,6 +88,8 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
'volume_letter',
|
||||
'consent_to_research',
|
||||
'count_as_live',
|
||||
'go_live_user',
|
||||
'go_live_at'
|
||||
}
|
||||
if disallowed_attributes:
|
||||
raise TypeError('Not allowed to update service attributes: {}'.format(
|
||||
@@ -102,6 +105,7 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
service_id,
|
||||
message_limit=250000 if live else 50,
|
||||
restricted=(not live),
|
||||
go_live_at=str(datetime.utcnow()) if live else None
|
||||
)
|
||||
|
||||
# This method is not cached because it calls through to one which is
|
||||
|
||||
@@ -416,6 +416,7 @@ def test_show_restricted_service(
|
||||
assert not request_to_live_link
|
||||
|
||||
|
||||
@freeze_time("2017-04-01 11:09:00.061258")
|
||||
def test_switch_service_to_live(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
@@ -437,7 +438,8 @@ def test_switch_service_to_live(
|
||||
mock_update_service.assert_called_with(
|
||||
SERVICE_ONE_ID,
|
||||
message_limit=250000,
|
||||
restricted=False
|
||||
restricted=False,
|
||||
go_live_at="2017-04-01 11:09:00.061258"
|
||||
)
|
||||
|
||||
|
||||
@@ -481,6 +483,7 @@ def test_switch_service_to_restricted(
|
||||
SERVICE_ONE_ID,
|
||||
message_limit=50,
|
||||
restricted=True,
|
||||
go_live_at=None
|
||||
)
|
||||
|
||||
|
||||
@@ -1319,7 +1322,7 @@ def test_non_gov_users_cant_request_to_go_live(
|
||||
[],
|
||||
),
|
||||
))
|
||||
@freeze_time("2012-12-21")
|
||||
@freeze_time("2012-12-21 13:12:12.12354")
|
||||
def test_should_redirect_after_request_to_go_live(
|
||||
client_request,
|
||||
mocker,
|
||||
@@ -1331,6 +1334,7 @@ def test_should_redirect_after_request_to_go_live(
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
mock_get_users_by_service,
|
||||
mock_update_service,
|
||||
mock_get_invites_without_manage_permission,
|
||||
volumes,
|
||||
displayed_volumes,
|
||||
@@ -1397,6 +1401,10 @@ def test_should_redirect_after_request_to_go_live(
|
||||
assert normalize_spaces(page.select_one('h1').text) == (
|
||||
'Settings'
|
||||
)
|
||||
mock_update_service.assert_called_once_with(
|
||||
SERVICE_ONE_ID,
|
||||
go_live_user=active_user_with_permissions.id
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user