mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-04 15:48:25 -04:00
org links don't show if user doesn't have permissions
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
&-item,
|
&-item,
|
||||||
&-sub-item {
|
&-sub-item {
|
||||||
|
@include bold-24;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
margin-bottom: $gutter-half;
|
margin-bottom: $gutter-half;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ def add_organisation():
|
|||||||
@user_has_permissions()
|
@user_has_permissions()
|
||||||
def organisation_dashboard(org_id):
|
def organisation_dashboard(org_id):
|
||||||
organisation_services = organisations_client.get_organisation_services(org_id)
|
organisation_services = organisations_client.get_organisation_services(org_id)
|
||||||
|
for service in organisation_services:
|
||||||
|
has_permission = current_user.has_permission_for_service(service['id'], 'view_activity')
|
||||||
|
service.update({'has_permission_to_view': has_permission})
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/organisations/organisation/index.html',
|
'views/organisations/organisation/index.html',
|
||||||
|
|||||||
@@ -16,7 +16,11 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{% for service in organisation_services %}
|
{% for service in organisation_services %}
|
||||||
<li class="browse-list-item">
|
<li class="browse-list-item">
|
||||||
<a href="{{ url_for('main.service_dashboard', service_id=service['id']) }}" class="browse-list-link">{{ service['name'] }}</a>
|
{% if service.has_permission_to_view %}
|
||||||
|
<a href="{{ url_for('main.service_dashboard', service_id=service['id']) }}" class="browse-list-link">{{ service['name'] }}</a>
|
||||||
|
{% else %}
|
||||||
|
{{ service['name'] }}
|
||||||
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -99,14 +99,17 @@ def test_organisation_services_show(
|
|||||||
|
|
||||||
assert len(page.select('.browse-list-item')) == 3
|
assert len(page.select('.browse-list-item')) == 3
|
||||||
|
|
||||||
for i in range(0, 3):
|
for i in range(0, 2):
|
||||||
service_name = mock_get_organisation_services(mock_get_organisation['id'])[i]['name']
|
service_name = mock_get_organisation_services(mock_get_organisation['id'])[i]['name']
|
||||||
service_id = mock_get_organisation_services(mock_get_organisation['id'])[i]['id']
|
service_id = mock_get_organisation_services(mock_get_organisation['id'])[i]['id']
|
||||||
|
|
||||||
assert normalize_spaces(page.select('.browse-list-item')[i].text) == service_name
|
assert normalize_spaces(page.select('.browse-list-item')[i].text) == service_name
|
||||||
assert normalize_spaces(
|
if i > 1:
|
||||||
page.select('.browse-list-item a')[i]['href']
|
assert normalize_spaces(
|
||||||
) == '/services/{}'.format(service_id)
|
page.select('.browse-list-item a')[i]['href']
|
||||||
|
) == '/services/{}'.format(service_id)
|
||||||
|
else:
|
||||||
|
assert page.select('.browse-list-item')[i].find('a') is None
|
||||||
|
|
||||||
|
|
||||||
def test_view_team_members(
|
def test_view_team_members(
|
||||||
|
|||||||
@@ -2756,12 +2756,12 @@ def mock_update_service_organisation(mocker):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_get_organisation_services(mocker):
|
def mock_get_organisation_services(mocker, api_user_active):
|
||||||
def _get_organisation_services(organisation_id):
|
def _get_organisation_services(organisation_id):
|
||||||
return [
|
return [
|
||||||
service_json('12345', 'service one'),
|
service_json('12345', 'service one'),
|
||||||
service_json('67890', 'service two'),
|
service_json('67890', 'service two'),
|
||||||
service_json('09876', 'service three')
|
service_json(SERVICE_ONE_ID, 'service one', [api_user_active.id])
|
||||||
]
|
]
|
||||||
|
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
|
|||||||
Reference in New Issue
Block a user