mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-16 19:30:13 -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")
|
||||
@login_required
|
||||
def choose_account():
|
||||
orgs_and_services = current_user.orgs_and_services
|
||||
|
||||
return render_template(
|
||||
'views/choose-account.html',
|
||||
services_without_organisations=orgs_and_services['services_without_organisations'],
|
||||
can_add_service=current_user.is_gov_user,
|
||||
)
|
||||
|
||||
|
||||
@@ -268,6 +268,13 @@ class User(JSONModel, UserMixin):
|
||||
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
|
||||
def organisations(self):
|
||||
return [
|
||||
|
||||
@@ -15,28 +15,26 @@
|
||||
<li class="browse-list-item">
|
||||
<a href="{{ url_for('.organisations') }}" class="browse-list-link">All organisations</a>
|
||||
</li>
|
||||
<div class="keyline-block"></div>
|
||||
<div class ="keyline-block"></div>
|
||||
{% endif %}
|
||||
{% for org in current_user.organisations %}
|
||||
<li class="browse-list-item">
|
||||
<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>
|
||||
<div class="keyline-block"></div>
|
||||
{% endfor %}
|
||||
{% if services_without_organisations %}
|
||||
{% for item in services_without_organisations %}
|
||||
{% if current_user.organisations %}
|
||||
{% for org in current_user.organisations %}
|
||||
<li class="browse-list-item">
|
||||
<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>
|
||||
<div class ="keyline-block"></div>
|
||||
{% endfor %}
|
||||
{% for item in current_user.live_services_not_belonging_to_users_organisations %}
|
||||
<li class="browse-list-item">
|
||||
<a href="{{ url_for('.service_dashboard', service_id=item.id) }}" class="browse-list-link">{{ item.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<div class="keyline-block"></div>
|
||||
{% endif %}
|
||||
{% if not current_user.organisations %}
|
||||
{% if current_user.trial_mode_services %}
|
||||
{% else %}
|
||||
{% if current_user.trial_mode_services and current_user.live_services %}
|
||||
</ul>
|
||||
<h2 class="heading-small">
|
||||
Live services
|
||||
|
||||
@@ -59,9 +59,8 @@ def test_choose_account_should_show_choose_accounts_page(
|
||||
page = resp.find('div', {'id': 'content'}).main
|
||||
|
||||
assert normalize_spaces(page.h1.text) == 'Choose service'
|
||||
outer_list_items = page.nav.ul.find_all('li', recursive=False)
|
||||
|
||||
assert len(outer_list_items) == 6
|
||||
outer_list_items = page.select('nav ul')[0].select('li')
|
||||
assert len(outer_list_items) == 5
|
||||
|
||||
# first org
|
||||
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'
|
||||
)
|
||||
|
||||
# orphaned services
|
||||
# orphaned live services
|
||||
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[4].a.text == 'service_2'
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user