mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-25 11:40:58 -04:00
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.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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'])
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 %}
|
||||
<div class="keyline-block"> </div>
|
||||
<div>
|
||||
<div>
|
||||
{{ browse_list([org]) }}
|
||||
</div>
|
||||
<div style="margin-left: 30px">
|
||||
{{ browse_list(org.services) }}
|
||||
</div>
|
||||
<nav>
|
||||
<div class="browse-list-item">
|
||||
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
||||
</div>
|
||||
<div style="margin-left: 30px" class="browse-list">
|
||||
<ul>
|
||||
{% for item in org.services %}
|
||||
<li class="browse-list-item">
|
||||
<a href="{{ url_for('.service_dashboard', service_id=item.id) }}" class="browse-list-link">{{ item.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if services_without_organisations %}
|
||||
<div class="keyline-block"> </div>
|
||||
<div>
|
||||
{{ browse_list(services_without_organisations) }}
|
||||
</div>
|
||||
<nav class="browse-list">
|
||||
<ul>
|
||||
{% for item in services_without_organisations %}
|
||||
<li class="browse-list-item">
|
||||
<a href="{{ url_for('.service_dashboard', service_id=item.id) }}" class="browse-list-link">{{ item.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
{% if can_add_service %}
|
||||
<div class="keyline-block"> </div>
|
||||
{{ browse_list([
|
||||
{
|
||||
'title': 'Add a new service…',
|
||||
'link': url_for('.add_service')
|
||||
},
|
||||
]) }}
|
||||
<nav class="browse-list">
|
||||
<div class="browse-list-item">
|
||||
<a href="{{ url_for('.add_service') }}" class="browse-list-link">Add a new service…</a>
|
||||
</div>
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
26
app/utils.py
26
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)
|
||||
|
||||
Reference in New Issue
Block a user