mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 03:38:26 -04:00
Only show live services without an organisation
In reality we shouldn’t have any live services that don’t have an organisation. But we probably do locally, in preview, etc., and we shouldn’t lose a way of accessing them.
This commit is contained in:
@@ -18,11 +18,8 @@ def services_or_dashboard():
|
|||||||
@main.route("/accounts")
|
@main.route("/accounts")
|
||||||
@login_required
|
@login_required
|
||||||
def choose_account():
|
def choose_account():
|
||||||
orgs_and_services = current_user.orgs_and_services
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/choose-account.html',
|
'views/choose-account.html',
|
||||||
services_without_organisations=orgs_and_services['services_without_organisations'],
|
|
||||||
can_add_service=current_user.is_gov_user,
|
can_add_service=current_user.is_gov_user,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +268,13 @@ class User(JSONModel, UserMixin):
|
|||||||
if not service['restricted']
|
if not service['restricted']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def live_services_not_belonging_to_users_organisations(self):
|
||||||
|
return [
|
||||||
|
service for service in self.orgs_and_services['services_without_organisations']
|
||||||
|
if not service['restricted']
|
||||||
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def organisations(self):
|
def organisations(self):
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -15,28 +15,26 @@
|
|||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('.organisations') }}" class="browse-list-link">All organisations</a>
|
<a href="{{ url_for('.organisations') }}" class="browse-list-link">All organisations</a>
|
||||||
</li>
|
</li>
|
||||||
<div class="keyline-block"></div>
|
<div class ="keyline-block"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for org in current_user.organisations %}
|
{% if current_user.organisations %}
|
||||||
<li class="browse-list-item">
|
{% for org in current_user.organisations %}
|
||||||
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
<li class="browse-list-item">
|
||||||
<p class="browse-list-hint">
|
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
||||||
{{ org.live_services|length }}
|
<p class="browse-list-hint">
|
||||||
live service{% if org.live_services|length != 1 %}s{% endif %}
|
{{ org.live_services|length }}
|
||||||
</p>
|
live service{% if org.live_services|length != 1 %}s{% endif %}
|
||||||
</li>
|
</p>
|
||||||
<div class="keyline-block"></div>
|
</li>
|
||||||
{% endfor %}
|
<div class ="keyline-block"></div>
|
||||||
{% if services_without_organisations %}
|
{% endfor %}
|
||||||
{% for item in services_without_organisations %}
|
{% for item in current_user.live_services_not_belonging_to_users_organisations %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('.service_dashboard', service_id=item.id) }}" class="browse-list-link">{{ item.name }}</a>
|
<a href="{{ url_for('.service_dashboard', service_id=item.id) }}" class="browse-list-link">{{ item.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="keyline-block"></div>
|
{% else %}
|
||||||
{% endif %}
|
{% if current_user.trial_mode_services and current_user.live_services %}
|
||||||
{% if not current_user.organisations %}
|
|
||||||
{% if current_user.trial_mode_services %}
|
|
||||||
</ul>
|
</ul>
|
||||||
<h2 class="heading-small">
|
<h2 class="heading-small">
|
||||||
Live services
|
Live services
|
||||||
|
|||||||
@@ -59,9 +59,8 @@ def test_choose_account_should_show_choose_accounts_page(
|
|||||||
page = resp.find('div', {'id': 'content'}).main
|
page = resp.find('div', {'id': 'content'}).main
|
||||||
|
|
||||||
assert normalize_spaces(page.h1.text) == 'Choose service'
|
assert normalize_spaces(page.h1.text) == 'Choose service'
|
||||||
outer_list_items = page.nav.ul.find_all('li', recursive=False)
|
outer_list_items = page.select('nav ul')[0].select('li')
|
||||||
|
assert len(outer_list_items) == 5
|
||||||
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'
|
||||||
@@ -84,13 +83,19 @@ def test_choose_account_should_show_choose_accounts_page(
|
|||||||
'0 live services'
|
'0 live services'
|
||||||
)
|
)
|
||||||
|
|
||||||
# orphaned services
|
# orphaned live services
|
||||||
assert outer_list_items[3].a.text == 'service_1'
|
assert outer_list_items[3].a.text == 'service_1'
|
||||||
assert outer_list_items[3].a['href'] == url_for('.service_dashboard', service_id='s1')
|
assert outer_list_items[3].a['href'] == url_for('.service_dashboard', service_id='s1')
|
||||||
assert outer_list_items[4].a.text == 'service_2'
|
assert outer_list_items[4].a.text == 'service_2'
|
||||||
assert outer_list_items[4].a['href'] == url_for('.service_dashboard', service_id='s2')
|
assert outer_list_items[4].a['href'] == url_for('.service_dashboard', service_id='s2')
|
||||||
assert outer_list_items[5].a.text == 'service_3'
|
|
||||||
assert outer_list_items[5].a['href'] == url_for('.service_dashboard', service_id='s3')
|
# orphaned live services
|
||||||
|
trial_services_list_items = page.select('nav ul')[1].select('li')
|
||||||
|
assert len(trial_services_list_items) == 2
|
||||||
|
assert trial_services_list_items[0].a.text == 'org_service_3'
|
||||||
|
assert trial_services_list_items[0].a['href'] == url_for('.service_dashboard', service_id='os3')
|
||||||
|
assert trial_services_list_items[1].a.text == 'service_3'
|
||||||
|
assert trial_services_list_items[1].a['href'] == url_for('.service_dashboard', service_id='s3')
|
||||||
|
|
||||||
|
|
||||||
def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
||||||
|
|||||||
Reference in New Issue
Block a user