diff --git a/app/main/views/choose_service.py b/app/main/views/choose_service.py index d0eb9a3af..cb5ab563b 100644 --- a/app/main/views/choose_service.py +++ b/app/main/views/choose_service.py @@ -1,19 +1,30 @@ from flask import redirect, render_template, session, url_for from flask_login import current_user, login_required -from app import service_api_client +from app import user_api_client from app.main import main from app.notify_client.service_api_client import ServicesBrowsableItem +from app.notify_client.organisations_api_client import OrganisationBrowsableItem from app.utils import is_gov_user @main.route("/services") @login_required def choose_service(): + orgs_and_services = user_api_client.get_organisations_and_services_for_user(current_user) + from pprint import pprint + pprint(orgs_and_services) + orgs_and_services['organisations'] = [ + OrganisationBrowsableItem(org) for org in orgs_and_services['organisations'] + ] + orgs_and_services['services_without_organisations'] = [ + ServicesBrowsableItem(x) for x in orgs_and_services['services_without_organisations'] + ] + return render_template( 'views/choose-service.html', - services=[ServicesBrowsableItem(x) for x in - service_api_client.get_active_services({'user_id': current_user.id})['data']], + organisations=orgs_and_services['organisations'], + services_without_organisations=orgs_and_services['services_without_organisations'], can_add_service=is_gov_user(current_user.email_address) ) diff --git a/app/templates/views/choose-service.html b/app/templates/views/choose-service.html index 37d8b5c65..24362359f 100644 --- a/app/templates/views/choose-service.html +++ b/app/templates/views/choose-service.html @@ -11,8 +11,25 @@ Choose service - {{ browse_list(services) }} + {% for org in organisations %} +
 
+
+
+ {{ browse_list([org]) }} +
+
+ {{ browse_list(org.services) }} +
+
+ {% endfor %} + {% if services_without_organisations %} +
 
+
+ {{ browse_list(services_without_organisations) }} +
+ {% endif %} {% if can_add_service %} +
 
{{ browse_list([ { 'title': 'Add a new service…', diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 5906dacb2..ba5ab94a6 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -1,6 +1,5 @@ {% extends "withnav_template.html" %} {% from "components/banner.html" import banner_wrapper %} -{% from "components/browse-list.html" import browse_list %} {% from "components/table.html" import mapping_table, row, text_field, optional_text_field, edit_field, field, boolean_field with context %} {% block service_page_title %}