mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 01:55:41 -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 import user_api_client
|
||||||
from app.main import main
|
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
|
from app.utils import is_gov_user
|
||||||
|
|
||||||
|
|
||||||
@@ -12,13 +10,6 @@ from app.utils import is_gov_user
|
|||||||
@login_required
|
@login_required
|
||||||
def choose_service():
|
def choose_service():
|
||||||
orgs_and_services = user_api_client.get_organisations_and_services_for_user(current_user)
|
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(
|
return render_template(
|
||||||
'views/choose-service.html',
|
'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 import NotifyAdminAPIClient, _attach_current_user
|
||||||
from app.notify_client.service_api_client import ServicesBrowsableItem
|
|
||||||
|
|
||||||
|
|
||||||
class OrganisationsClient(NotifyAdminAPIClient):
|
class OrganisationsClient(NotifyAdminAPIClient):
|
||||||
@@ -54,12 +51,3 @@ class OrganisationsClient(NotifyAdminAPIClient):
|
|||||||
url="/organisations/unique",
|
url="/organisations/unique",
|
||||||
params={"org_id": org_id, "name": name}
|
params={"org_id": org_id, "name": name}
|
||||||
)["result"]
|
)["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 __future__ import unicode_literals
|
||||||
|
|
||||||
from flask import url_for
|
|
||||||
|
|
||||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||||
from app.utils import BrowsableItem
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceAPIClient(NotifyAdminAPIClient):
|
class ServiceAPIClient(NotifyAdminAPIClient):
|
||||||
@@ -426,21 +423,3 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
|||||||
"updated_by_id": user_id
|
"updated_by_id": user_id
|
||||||
}
|
}
|
||||||
return self.post("/service/{}/delivery-receipt-api".format(service_id), data)
|
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" %}
|
{% extends "withoutnav_template.html" %}
|
||||||
{% from "components/browse-list.html" import browse_list %}
|
|
||||||
|
|
||||||
{% block per_page_title %}
|
{% block per_page_title %}
|
||||||
Choose service
|
Choose service
|
||||||
@@ -14,29 +13,41 @@
|
|||||||
{% for org in organisations %}
|
{% for org in organisations %}
|
||||||
<div class="keyline-block"> </div>
|
<div class="keyline-block"> </div>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<nav>
|
||||||
{{ browse_list([org]) }}
|
<div class="browse-list-item">
|
||||||
</div>
|
<a href="{{ url_for('.organisation_dashboard', org_id=org.id) }}" class="browse-list-link">{{ org.name }}</a>
|
||||||
<div style="margin-left: 30px">
|
</div>
|
||||||
{{ browse_list(org.services) }}
|
<div style="margin-left: 30px" class="browse-list">
|
||||||
</div>
|
<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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if services_without_organisations %}
|
{% if services_without_organisations %}
|
||||||
<div class="keyline-block"> </div>
|
<div class="keyline-block"> </div>
|
||||||
<div>
|
<nav class="browse-list">
|
||||||
{{ browse_list(services_without_organisations) }}
|
<ul>
|
||||||
</div>
|
{% 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 %}
|
{% endif %}
|
||||||
{% if can_add_service %}
|
{% if can_add_service %}
|
||||||
<div class="keyline-block"> </div>
|
<div class="keyline-block"> </div>
|
||||||
{{ browse_list([
|
<nav class="browse-list">
|
||||||
{
|
<div class="browse-list-item">
|
||||||
'title': 'Add a new service…',
|
<a href="{{ url_for('.add_service') }}" class="browse-list-link">Add a new service…</a>
|
||||||
'link': url_for('.add_service')
|
</div>
|
||||||
},
|
</nav>
|
||||||
]) }}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% 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
|
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 user_has_permissions(*permissions, **permission_kwargs):
|
||||||
def wrap(func):
|
def wrap(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
|
|||||||
Reference in New Issue
Block a user