mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-03-02 07:11:14 -05:00
get orgs and services from user
this endpoint should probably only be used for the choose-service page also create an OrganisationBrowsableItem to aid rendering of them in the front-end.
This commit is contained in:
@@ -68,6 +68,7 @@ class User(UserMixin):
|
||||
self.max_failed_login_count = max_failed_login_count
|
||||
self.platform_admin = fields.get('platform_admin')
|
||||
self.current_session_id = fields.get('current_session_id')
|
||||
self.services = fields.get('services', [])
|
||||
self.organisations = fields.get('organisations', [])
|
||||
|
||||
def _set_permissions(self, permissions_by_service):
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
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):
|
||||
@@ -51,3 +54,12 @@ 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'])
|
||||
|
||||
@@ -185,3 +185,7 @@ class UserApiClient(NotifyAdminAPIClient):
|
||||
endpoint = '/user/{}/change-email-verification'.format(user_id)
|
||||
data = {'email': new_email}
|
||||
self.post(endpoint, data)
|
||||
|
||||
def get_organisations_and_services_for_user(self, user):
|
||||
endpoint = '/user/{}/organisations-and-services'.format(user.id)
|
||||
return self.get(endpoint)
|
||||
|
||||
@@ -33,14 +33,14 @@ FAILURE_STATUSES = ['failed', 'temporary-failure', 'permanent-failure', 'technic
|
||||
REQUESTED_STATUSES = SENDING_STATUSES + DELIVERED_STATUSES + FAILURE_STATUSES
|
||||
|
||||
|
||||
class BrowsableItem(object):
|
||||
class BrowsableItem:
|
||||
"""
|
||||
Maps for the template browse-list.
|
||||
"""
|
||||
|
||||
def __init__(self, item, *args, **kwargs):
|
||||
print(self, item)
|
||||
self._item = item
|
||||
super(BrowsableItem, self).__init__()
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
|
||||
Reference in New Issue
Block a user