From dfa3a9242f2259efb354efa73a7abadf122265eb Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 20 Sep 2016 11:38:22 +0100 Subject: [PATCH] Add a separate page for linking to documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s going to get too cluttered to have these links on the API index page. --- app/main/views/api_keys.py | 9 ++++++ app/templates/views/api/documentation.html | 35 ++++++++++++++++++++++ app/templates/views/api/index.html | 16 +--------- tests/app/main/views/test_api_keys.py | 15 ++++++++++ 4 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 app/templates/views/api/documentation.html diff --git a/app/main/views/api_keys.py b/app/main/views/api_keys.py index 4525a0365..757801e77 100644 --- a/app/main/views/api_keys.py +++ b/app/main/views/api_keys.py @@ -16,6 +16,15 @@ def api_integration(service_id): ) +@main.route("/services//api/documentation") +@login_required +@user_has_permissions('manage_api_keys') +def api_documentation(service_id): + return render_template( + 'views/api/documentation.html' + ) + + @main.route("/services//api/keys") @login_required @user_has_permissions('manage_api_keys') diff --git a/app/templates/views/api/documentation.html b/app/templates/views/api/documentation.html new file mode 100644 index 000000000..44460340c --- /dev/null +++ b/app/templates/views/api/documentation.html @@ -0,0 +1,35 @@ +{% extends "withnav_template.html" %} +{% from "components/table.html" import list_table, field, hidden_field_heading %} +{% from "components/api-key.html" import api_key %} +{% from "components/page-footer.html" import page_footer %} + +{% block page_title %} + API integration – GOV.UK Notify +{% endblock %} + +{% block maincolumn_content %} + +

+ Documentation +

+ +
    + {% for name, url in [ + ('Java client', 'https://github.com/alphagov/notifications-java-client'), + ('Node JS client', 'https://github.com/alphagov/notifications-node-client'), + ('PHP client', 'https://github.com/alphagov/notifications-php-client'), + ('Python client', 'https://github.com/alphagov/notifications-python-client'), + ('Ruby client', 'https://github.com/alphagov/notifications-ruby-client') + ] %} +
  • + {{ name }} +
  • + {% endfor %} +
+ + {{ page_footer( + secondary_link=url_for('.api_integration', service_id=current_service.id), + secondary_link_text='Back to API integration' + ) }} + +{% endblock %} diff --git a/app/templates/views/api/index.html b/app/templates/views/api/index.html index 6810e5147..db6586550 100644 --- a/app/templates/views/api/index.html +++ b/app/templates/views/api/index.html @@ -13,20 +13,6 @@ API keys - -

API clients

-
    - {% for name, url in [ - ('Java', 'https://github.com/alphagov/notifications-java-client'), - ('Node JS', 'https://github.com/alphagov/notifications-node-client'), - ('PHP', 'https://github.com/alphagov/notifications-php-client'), - ('Python', 'https://quis.github.io/govuk_documentation_prototype/'), - ('Ruby', 'https://github.com/alphagov/notifications-ruby-client') - ] %} -
  • - {{ name }} -
  • - {% endfor %} -
+ Documentation {% endblock %} diff --git a/tests/app/main/views/test_api_keys.py b/tests/app/main/views/test_api_keys.py index 54ba99199..3131c5289 100644 --- a/tests/app/main/views/test_api_keys.py +++ b/tests/app/main/views/test_api_keys.py @@ -21,6 +21,21 @@ def test_should_show_api_page( assert page.h1.string.strip() == 'API integration' +def test_should_show_api_documentation_page( + app_, + mock_login, + api_user_active, + mock_get_service, + mock_has_permissions +): + with app_.test_request_context(), app_.test_client() as client: + client.login(api_user_active) + response = client.get(url_for('main.api_documentation', service_id=str(uuid.uuid4()))) + assert response.status_code == 200 + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.h1.string.strip() == 'Documentation' + + def test_should_show_empty_api_keys_page(app_, api_user_pending, mock_login,