From 1cd8000236cbb7e4518745c5a31a3c8832d58733 Mon Sep 17 00:00:00 2001 From: Leo Hemsted Date: Thu, 8 Mar 2018 14:15:01 +0000 Subject: [PATCH] remove browsableitem it was only used by the choose service page, and then only in kludgy ways (eg: creating a list containing one item called "add service"), so lets rip it out and make this page bespoke. Especially now that it's changed so much. --- app/main/views/choose_service.py | 9 ---- app/notify_client/organisations_api_client.py | 12 ----- app/notify_client/service_api_client.py | 21 --------- app/templates/views/choose-service.html | 45 ++++++++++++------- app/utils.py | 26 ----------- 5 files changed, 28 insertions(+), 85 deletions(-) diff --git a/app/main/views/choose_service.py b/app/main/views/choose_service.py index e253c822e..187d6aac0 100644 --- a/app/main/views/choose_service.py +++ b/app/main/views/choose_service.py @@ -3,8 +3,6 @@ from flask_login import current_user, login_required 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 @@ -12,13 +10,6 @@ from app.utils import is_gov_user @login_required def choose_service(): orgs_and_services = user_api_client.get_organisations_and_services_for_user(current_user) - from pprint import pprint - 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', diff --git a/app/notify_client/organisations_api_client.py b/app/notify_client/organisations_api_client.py index bc14576eb..52b0a9f06 100644 --- a/app/notify_client/organisations_api_client.py +++ b/app/notify_client/organisations_api_client.py @@ -1,7 +1,4 @@ -from flask import url_for - from app.notify_client import NotifyAdminAPIClient, _attach_current_user -from app.notify_client.service_api_client import ServicesBrowsableItem class OrganisationsClient(NotifyAdminAPIClient): @@ -54,12 +51,3 @@ class OrganisationsClient(NotifyAdminAPIClient): url="/organisations/unique", params={"org_id": org_id, "name": name} )["result"] - -class OrganisationBrowsableItem(ServicesBrowsableItem): - def __init__(self, organisation): - self.services = [ServicesBrowsableItem(x) for x in organisation['services']] - super().__init__(organisation) - - @property - def link(self): - return url_for('main.organisation_dashboard', org_id=self._item['id']) diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index d6119f409..5635dcb5f 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -1,9 +1,6 @@ from __future__ import unicode_literals -from flask import url_for - from app.notify_client import NotifyAdminAPIClient, _attach_current_user -from app.utils import BrowsableItem class ServiceAPIClient(NotifyAdminAPIClient): @@ -426,21 +423,3 @@ class ServiceAPIClient(NotifyAdminAPIClient): "updated_by_id": user_id } return self.post("/service/{}/delivery-receipt-api".format(service_id), data) - - -class ServicesBrowsableItem(BrowsableItem): - @property - def title(self): - return self._item['name'] - - @property - def link(self): - return url_for('main.service_dashboard', service_id=self._item['id']) - - @property - def destructive(self): - return False - - @property - def hint(self): - return None diff --git a/app/templates/views/choose-service.html b/app/templates/views/choose-service.html index 24362359f..d1864c590 100644 --- a/app/templates/views/choose-service.html +++ b/app/templates/views/choose-service.html @@ -1,5 +1,4 @@ {% extends "withoutnav_template.html" %} -{% from "components/browse-list.html" import browse_list %} {% block per_page_title %} Choose service @@ -14,29 +13,41 @@ {% 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…', - 'link': url_for('.add_service') - }, - ]) }} + {% endif %} - {% endblock %} diff --git a/app/utils.py b/app/utils.py index a76b732bc..50825de60 100644 --- a/app/utils.py +++ b/app/utils.py @@ -33,32 +33,6 @@ FAILURE_STATUSES = ['failed', 'temporary-failure', 'permanent-failure', 'technic REQUESTED_STATUSES = SENDING_STATUSES + DELIVERED_STATUSES + FAILURE_STATUSES -class BrowsableItem: - """ - Maps for the template browse-list. - """ - - def __init__(self, item, *args, **kwargs): - print(self, item) - self._item = item - - @property - def title(self): - pass - - @property - def link(self): - pass - - @property - def hint(self): - pass - - @property - def destructive(self): - pass - - def user_has_permissions(*permissions, **permission_kwargs): def wrap(func): @wraps(func)