mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 17:45:32 -04:00
Add count of live services to organisations
This makes it clear that these are something different to the trial mode services, in that they are a container of multiple things.
This commit is contained in:
@@ -270,7 +270,10 @@ class User(JSONModel, UserMixin):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def organisations(self):
|
def organisations(self):
|
||||||
return self.orgs_and_services['organisations']
|
return [
|
||||||
|
Organisation.from_id(organisation['id'])
|
||||||
|
for organisation in self.orgs_and_services['organisations']
|
||||||
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def organisation_ids(self):
|
def organisation_ids(self):
|
||||||
|
|||||||
@@ -20,6 +20,10 @@
|
|||||||
{% for org in current_user.organisations %}
|
{% for org in current_user.organisations %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
||||||
|
<p class="browse-list-hint">
|
||||||
|
{{ org.live_services|length }}
|
||||||
|
live service{% if org.live_services|length != 1 %}s{% endif %}
|
||||||
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<div class="keyline-block"></div>
|
<div class="keyline-block"></div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ def mock_get_orgs_and_services(mocker):
|
|||||||
|
|
||||||
def test_choose_account_should_show_choose_accounts_page(
|
def test_choose_account_should_show_choose_accounts_page(
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_orgs_and_services
|
mock_get_orgs_and_services,
|
||||||
|
mock_get_organisation,
|
||||||
|
mock_get_organisation_services,
|
||||||
):
|
):
|
||||||
resp = client_request.get('main.choose_account')
|
resp = client_request.get('main.choose_account')
|
||||||
page = resp.find('div', {'id': 'content'}).main
|
page = resp.find('div', {'id': 'content'}).main
|
||||||
@@ -62,19 +64,25 @@ def test_choose_account_should_show_choose_accounts_page(
|
|||||||
assert len(outer_list_items) == 6
|
assert len(outer_list_items) == 6
|
||||||
|
|
||||||
# first org
|
# first org
|
||||||
assert outer_list_items[0].a.text == 'org_1'
|
assert outer_list_items[0].a.text == 'Org 1'
|
||||||
assert outer_list_items[0].a['href'] == url_for('.organisation_dashboard', org_id='o1')
|
assert outer_list_items[0].a['href'] == url_for('.organisation_dashboard', org_id='o1')
|
||||||
assert not outer_list_items[0].ul
|
assert normalize_spaces(outer_list_items[0].select_one('.browse-list-hint').text) == (
|
||||||
|
'1 live service'
|
||||||
|
)
|
||||||
|
|
||||||
# second org
|
# second org
|
||||||
assert outer_list_items[1].a.text == 'org_2'
|
assert outer_list_items[1].a.text == 'Org 2'
|
||||||
assert outer_list_items[1].a['href'] == url_for('.organisation_dashboard', org_id='o2')
|
assert outer_list_items[1].a['href'] == url_for('.organisation_dashboard', org_id='o2')
|
||||||
assert not outer_list_items[2].ul
|
assert normalize_spaces(outer_list_items[1].select_one('.browse-list-hint').text) == (
|
||||||
|
'2 live services'
|
||||||
|
)
|
||||||
|
|
||||||
# third org
|
# third org
|
||||||
assert outer_list_items[2].a.text == 'org_3'
|
assert outer_list_items[2].a.text == 'Org 3'
|
||||||
assert outer_list_items[2].a['href'] == url_for('.organisation_dashboard', org_id='o3')
|
assert outer_list_items[2].a['href'] == url_for('.organisation_dashboard', org_id='o3')
|
||||||
assert not outer_list_items[2].ul # org 3 has no services
|
assert normalize_spaces(outer_list_items[2].select_one('.browse-list-hint').text) == (
|
||||||
|
'0 live services'
|
||||||
|
)
|
||||||
|
|
||||||
# orphaned services
|
# orphaned services
|
||||||
assert outer_list_items[3].a.text == 'service_1'
|
assert outer_list_items[3].a.text == 'service_1'
|
||||||
@@ -87,7 +95,9 @@ def test_choose_account_should_show_choose_accounts_page(
|
|||||||
|
|
||||||
def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_orgs_and_services
|
mock_get_orgs_and_services,
|
||||||
|
mock_get_organisation,
|
||||||
|
mock_get_organisation_services,
|
||||||
):
|
):
|
||||||
mock_get_orgs_and_services.return_value = {
|
mock_get_orgs_and_services.return_value = {
|
||||||
'organisations': [],
|
'organisations': [],
|
||||||
@@ -122,7 +132,9 @@ def test_choose_account_should_should_organisations_link_for_platform_admin(
|
|||||||
|
|
||||||
def test_choose_account_should_show_back_to_service_link(
|
def test_choose_account_should_show_back_to_service_link(
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_orgs_and_services
|
mock_get_orgs_and_services,
|
||||||
|
mock_get_organisation,
|
||||||
|
mock_get_organisation_services,
|
||||||
):
|
):
|
||||||
resp = client_request.get('main.choose_account')
|
resp = client_request.get('main.choose_account')
|
||||||
|
|
||||||
@@ -136,7 +148,9 @@ def test_choose_account_should_show_back_to_service_link(
|
|||||||
def test_choose_account_should_not_show_back_to_service_link_if_no_service_in_session(
|
def test_choose_account_should_not_show_back_to_service_link_if_no_service_in_session(
|
||||||
client,
|
client,
|
||||||
client_request,
|
client_request,
|
||||||
mock_get_orgs_and_services
|
mock_get_orgs_and_services,
|
||||||
|
mock_get_organisation,
|
||||||
|
mock_get_organisation_services,
|
||||||
):
|
):
|
||||||
with client.session_transaction() as session:
|
with client.session_transaction() as session:
|
||||||
session['service_id'] = None
|
session['service_id'] = None
|
||||||
@@ -166,6 +180,8 @@ def test_choose_account_should_not_show_back_to_service_link_if_service_archived
|
|||||||
client_request,
|
client_request,
|
||||||
service_one,
|
service_one,
|
||||||
mock_get_orgs_and_services,
|
mock_get_orgs_and_services,
|
||||||
|
mock_get_organisation,
|
||||||
|
mock_get_organisation_services,
|
||||||
active,
|
active,
|
||||||
):
|
):
|
||||||
service_one['active'] = active
|
service_one['active'] = active
|
||||||
|
|||||||
@@ -3136,7 +3136,11 @@ def mock_get_organisation(
|
|||||||
def _get_organisation(org_id):
|
def _get_organisation(org_id):
|
||||||
return organisation_json(
|
return organisation_json(
|
||||||
org_id,
|
org_id,
|
||||||
'Org 1',
|
{
|
||||||
|
'o1': 'Org 1',
|
||||||
|
'o2': 'Org 2',
|
||||||
|
'o3': 'Org 3',
|
||||||
|
}.get(org_id, 'Org 1'),
|
||||||
email_branding_id=email_branding_id,
|
email_branding_id=email_branding_id,
|
||||||
letter_branding_id=letter_branding_id,
|
letter_branding_id=letter_branding_id,
|
||||||
)
|
)
|
||||||
@@ -3199,6 +3203,18 @@ def mock_update_service_organisation(mocker):
|
|||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_get_organisation_services(mocker, api_user_active):
|
def mock_get_organisation_services(mocker, api_user_active):
|
||||||
def _get_organisation_services(organisation_id):
|
def _get_organisation_services(organisation_id):
|
||||||
|
if organisation_id == 'o1':
|
||||||
|
return [
|
||||||
|
service_json('12345', 'service one', restricted=False),
|
||||||
|
service_json('67890', 'service two'),
|
||||||
|
service_json('abcde', 'service three'),
|
||||||
|
]
|
||||||
|
if organisation_id == 'o2':
|
||||||
|
return [
|
||||||
|
service_json('12345', 'service one', restricted=False),
|
||||||
|
service_json('67890', 'service two', restricted=False),
|
||||||
|
service_json('abcde', 'service three'),
|
||||||
|
]
|
||||||
return [
|
return [
|
||||||
service_json('12345', 'service one'),
|
service_json('12345', 'service one'),
|
||||||
service_json('67890', 'service two'),
|
service_json('67890', 'service two'),
|
||||||
|
|||||||
Reference in New Issue
Block a user