Link to all services from organisation

Because a member of the organisation can now see some pages for any live
service they should be able to click into each one.
This commit is contained in:
Chris Hill-Scott
2019-06-20 10:35:55 +01:00
parent 3968d5b766
commit afedf431e0
4 changed files with 8 additions and 17 deletions

View File

@@ -70,13 +70,8 @@ def add_organisation():
@login_required
@user_has_permissions()
def organisation_dashboard(org_id):
for service in current_organisation.live_services:
has_permission = current_user.has_permission_for_service(service['id'], 'view_activity')
service.update({'has_permission_to_view': has_permission})
return render_template(
'views/organisations/organisation/index.html',
organisation_services=current_organisation.live_services
)
@@ -87,7 +82,6 @@ def organisation_trial_mode_services(org_id):
return render_template(
'views/organisations/organisation/trial-mode-services.html',
search_form=SearchByNameForm(),
services=current_organisation.trial_services
)

View File

@@ -10,13 +10,9 @@
Services
</h1>
<ul>
{% for service in organisation_services %}
{% for service in current_org.live_services %}
<li class="browse-list-item">
{% if service.has_permission_to_view or current_user.platform_admin %}
<a href="{{ url_for('main.service_dashboard', service_id=service.id) }}" class="browse-list-link">{{ service['name'] }}</a>
{% else %}
{{ service['name'] }}
{% endif %}
<a href="{{ url_for('main.service_dashboard', service_id=service.id) }}" class="browse-list-link">{{ service['name'] }}</a>
</li>
{% endfor %}
</ul>

View File

@@ -12,7 +12,7 @@
</h1>
{{ live_search(target_selector='.browse-list-item', show=True, form=search_form, label='Search by name') }}
<ul>
{% for service in services %}
{% for service in current_org.trial_services %}
<li class="browse-list-item">
<a href="{{ url_for('main.service_dashboard', service_id=service.id) }}" class="browse-list-link">{{ service['name'] }}</a>
</li>

View File

@@ -9,6 +9,7 @@ from tests import organisation_json, service_json
from tests.conftest import (
ORGANISATION_ID,
SERVICE_ONE_ID,
SERVICE_TWO_ID,
active_user_with_permissions,
normalize_spaces,
platform_admin_user,
@@ -104,11 +105,11 @@ def test_organisation_services_shows_live_services_only(
mocker.patch(
'app.organisations_client.get_organisation_services',
return_value=[
service_json(id_='1', name='1', restricted=False, active=True), # live
service_json(id_=SERVICE_ONE_ID, name='1', restricted=False, active=True), # live
service_json(id_='2', name='2', restricted=True, active=True), # trial
service_json(id_='3', name='3', restricted=True, active=False), # trial, now archived
service_json(id_='4', name='4', restricted=False, active=False), # was live, now archived
service_json(id_=SERVICE_ONE_ID, name='5', restricted=False, active=True), # live, member of
service_json(id_=SERVICE_TWO_ID, name='5', restricted=False, active=True), # live, member of
]
)
@@ -120,8 +121,8 @@ def test_organisation_services_shows_live_services_only(
assert normalize_spaces(services[0].text) == '1'
assert normalize_spaces(services[1].text) == '5'
assert services[0].find('a') is None
assert services[1].find('a')['href'] == url_for('main.service_dashboard', service_id=SERVICE_ONE_ID)
assert services[0].find('a')['href'] == url_for('main.service_dashboard', service_id=SERVICE_ONE_ID)
assert services[1].find('a')['href'] == url_for('main.service_dashboard', service_id=SERVICE_TWO_ID)
def test_organisation_trial_mode_services_shows_all_non_live_services(