mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 07:28:25 -04:00
Merge pull request #608 from alphagov/platform-admin-dashboard
New platform admin page
This commit is contained in:
@@ -12,7 +12,8 @@ from app.main.views import (
|
|||||||
send,
|
send,
|
||||||
add_service,
|
add_service,
|
||||||
code_not_received,
|
code_not_received,
|
||||||
jobs, dashboard,
|
jobs,
|
||||||
|
dashboard,
|
||||||
templates,
|
templates,
|
||||||
service_settings,
|
service_settings,
|
||||||
forgot_password,
|
forgot_password,
|
||||||
@@ -26,5 +27,6 @@ from app.main.views import (
|
|||||||
all_services,
|
all_services,
|
||||||
tour,
|
tour,
|
||||||
feedback,
|
feedback,
|
||||||
providers
|
providers,
|
||||||
|
platform_admin
|
||||||
)
|
)
|
||||||
|
|||||||
14
app/main/views/platform_admin.py
Normal file
14
app/main/views/platform_admin.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from flask import render_template
|
||||||
|
from flask_login import login_required
|
||||||
|
|
||||||
|
from app.main import main
|
||||||
|
from app.utils import user_has_permissions
|
||||||
|
|
||||||
|
|
||||||
|
@main.route("/platform-admin")
|
||||||
|
@login_required
|
||||||
|
@user_has_permissions(admin_override=True)
|
||||||
|
def platform_admin():
|
||||||
|
return render_template(
|
||||||
|
'views/platform-admin.html'
|
||||||
|
)
|
||||||
@@ -46,6 +46,11 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="{{ url_for('main.choose_service') }}">Switch service</a>
|
<a href="{{ url_for('main.choose_service') }}">Switch service</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if current_user.has_permissions(admin_override=True) %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('main.platform_admin') }}">Platform admin</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ url_for('main.sign_out')}}">Sign out</a>
|
<a href="{{ url_for('main.sign_out')}}">Sign out</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -16,11 +16,5 @@
|
|||||||
{% if current_user.has_permissions(['manage_api_keys']) %}
|
{% if current_user.has_permissions(['manage_api_keys']) %}
|
||||||
<li><a href="{{ url_for('.api_keys', service_id=current_service.id) }}">API keys</a></li>
|
<li><a href="{{ url_for('.api_keys', service_id=current_service.id) }}">API keys</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if current_user.has_permissions(admin_override=True) %}
|
|
||||||
<li><a href="{{ url_for('.show_all_services') }}"> List all services </a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% if current_user.has_permissions(admin_override=True) %}
|
|
||||||
<li><a href="{{ url_for('.view_providers') }}">View providers</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -10,14 +10,6 @@
|
|||||||
<h1 class="heading-large">
|
<h1 class="heading-large">
|
||||||
Choose service
|
Choose service
|
||||||
</h1>
|
</h1>
|
||||||
{% if current_user.has_permissions(admin_override=True) %}
|
|
||||||
{{ browse_list([
|
|
||||||
{
|
|
||||||
'title': 'List all services',
|
|
||||||
'link': url_for('.show_all_services')
|
|
||||||
}
|
|
||||||
]) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{{ browse_list(services) }}
|
{{ browse_list(services) }}
|
||||||
{{ browse_list([
|
{{ browse_list([
|
||||||
|
|||||||
25
app/templates/views/platform-admin.html
Normal file
25
app/templates/views/platform-admin.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{% extends "withoutnav_template.html" %}
|
||||||
|
{% from "components/browse-list.html" import browse_list %}
|
||||||
|
|
||||||
|
{% block page_title %}
|
||||||
|
Platform admin – GOV.UK Notify
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block maincolumn_content %}
|
||||||
|
|
||||||
|
<h1 class="heading-large">
|
||||||
|
Platform admin
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
{{ browse_list([
|
||||||
|
{
|
||||||
|
'title': 'List all services',
|
||||||
|
'link': url_for('.show_all_services')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'title': 'View providers',
|
||||||
|
'link': url_for('.view_providers')
|
||||||
|
},
|
||||||
|
]) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -83,23 +83,3 @@ def test_should_redirect_if_not_logged_in(app_):
|
|||||||
response = client.get(url_for('main.show_all_services_or_dashboard'))
|
response = client.get(url_for('main.show_all_services_or_dashboard'))
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
assert url_for('main.index', _external=True) in response.location
|
assert url_for('main.index', _external=True) in response.location
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_all_services_for_platform_admin_user(app_,
|
|
||||||
platform_admin_user,
|
|
||||||
mock_get_services,
|
|
||||||
mocker):
|
|
||||||
with app_.test_request_context():
|
|
||||||
with app_.test_client() as client:
|
|
||||||
mocker.patch('app.user_api_client.get_user', return_value=platform_admin_user)
|
|
||||||
client.login(platform_admin_user)
|
|
||||||
response = client.get(url_for('main.choose_service'))
|
|
||||||
|
|
||||||
assert response.status_code == 200
|
|
||||||
resp_data = response.get_data(as_text=True)
|
|
||||||
assert 'Choose service' in resp_data
|
|
||||||
services = mock_get_services.side_effect()
|
|
||||||
assert mock_get_services.called
|
|
||||||
assert services['data'][0]['name'] in resp_data
|
|
||||||
assert services['data'][1]['name'] in resp_data
|
|
||||||
assert 'List all services' in resp_data
|
|
||||||
|
|||||||
@@ -266,8 +266,6 @@ def test_menu_all_services_for_platform_admin_user(mocker,
|
|||||||
service_one,
|
service_one,
|
||||||
[])
|
[])
|
||||||
page = resp.get_data(as_text=True)
|
page = resp.get_data(as_text=True)
|
||||||
assert url_for('main.show_all_services') in page
|
|
||||||
assert url_for('main.view_providers') in page
|
|
||||||
assert url_for('main.choose_template', service_id=service_one['id'], template_type='sms') in page
|
assert url_for('main.choose_template', service_id=service_one['id'], template_type='sms') in page
|
||||||
assert url_for('main.choose_template', service_id=service_one['id'], template_type='email') in page
|
assert url_for('main.choose_template', service_id=service_one['id'], template_type='email') in page
|
||||||
assert url_for('main.manage_users', service_id=service_one['id']) in page
|
assert url_for('main.manage_users', service_id=service_one['id']) in page
|
||||||
|
|||||||
36
tests/app/main/views/test_platform_admin.py
Normal file
36
tests/app/main/views/test_platform_admin.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
from tests.conftest import mock_get_user
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_redirect_if_not_logged_in(app_):
|
||||||
|
with app_.test_request_context():
|
||||||
|
with app_.test_client() as client:
|
||||||
|
response = client.get(url_for('main.platform_admin'))
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert url_for('main.index', _external=True) in response.location
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_403_if_not_platform_admin(app_, active_user_with_permissions, mocker):
|
||||||
|
with app_.test_request_context():
|
||||||
|
with app_.test_client() as client:
|
||||||
|
mock_get_user(mocker, user=active_user_with_permissions)
|
||||||
|
client.login(active_user_with_permissions)
|
||||||
|
|
||||||
|
response = client.get(url_for('main.platform_admin'))
|
||||||
|
|
||||||
|
assert response.status_code == 403
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_render_platform_admin_page(app_, platform_admin_user, mocker):
|
||||||
|
with app_.test_request_context():
|
||||||
|
with app_.test_client() as client:
|
||||||
|
mock_get_user(mocker, user=platform_admin_user)
|
||||||
|
client.login(platform_admin_user)
|
||||||
|
response = client.get(url_for('main.platform_admin'))
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
resp_data = response.get_data(as_text=True)
|
||||||
|
assert 'Platform admin' in resp_data
|
||||||
|
assert 'List all services' in resp_data
|
||||||
|
assert 'View providers' in resp_data
|
||||||
Reference in New Issue
Block a user