mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04: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.max_failed_login_count = max_failed_login_count
|
||||||
self.platform_admin = fields.get('platform_admin')
|
self.platform_admin = fields.get('platform_admin')
|
||||||
self.current_session_id = fields.get('current_session_id')
|
self.current_session_id = fields.get('current_session_id')
|
||||||
|
self.services = fields.get('services', [])
|
||||||
self.organisations = fields.get('organisations', [])
|
self.organisations = fields.get('organisations', [])
|
||||||
|
|
||||||
def _set_permissions(self, permissions_by_service):
|
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 import NotifyAdminAPIClient, _attach_current_user
|
||||||
|
from app.notify_client.service_api_client import ServicesBrowsableItem
|
||||||
|
|
||||||
|
|
||||||
class OrganisationsClient(NotifyAdminAPIClient):
|
class OrganisationsClient(NotifyAdminAPIClient):
|
||||||
@@ -51,3 +54,12 @@ 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'])
|
||||||
|
|||||||
@@ -185,3 +185,7 @@ class UserApiClient(NotifyAdminAPIClient):
|
|||||||
endpoint = '/user/{}/change-email-verification'.format(user_id)
|
endpoint = '/user/{}/change-email-verification'.format(user_id)
|
||||||
data = {'email': new_email}
|
data = {'email': new_email}
|
||||||
self.post(endpoint, data)
|
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
|
REQUESTED_STATUSES = SENDING_STATUSES + DELIVERED_STATUSES + FAILURE_STATUSES
|
||||||
|
|
||||||
|
|
||||||
class BrowsableItem(object):
|
class BrowsableItem:
|
||||||
"""
|
"""
|
||||||
Maps for the template browse-list.
|
Maps for the template browse-list.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, item, *args, **kwargs):
|
def __init__(self, item, *args, **kwargs):
|
||||||
|
print(self, item)
|
||||||
self._item = item
|
self._item = item
|
||||||
super(BrowsableItem, self).__init__()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def title(self):
|
def title(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user