mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
blunt rename of org (#620)
This commit is contained in:
@@ -9,10 +9,10 @@ from app.models import (
|
||||
SortByNameMixin,
|
||||
)
|
||||
from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.organisations_api_client import organisations_client
|
||||
from app.notify_client.organizations_api_client import organizations_client
|
||||
|
||||
|
||||
class Organisation(JSONModel, SortByNameMixin):
|
||||
class Organization(JSONModel, SortByNameMixin):
|
||||
|
||||
TYPE_FEDERAL = 'federal'
|
||||
TYPE_STATE = 'state'
|
||||
@@ -28,7 +28,7 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
'id',
|
||||
'name',
|
||||
'active',
|
||||
'organisation_type',
|
||||
'organization_type',
|
||||
'email_branding_id',
|
||||
'domains',
|
||||
'request_to_go_live_notes',
|
||||
@@ -44,28 +44,28 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
def from_id(cls, org_id):
|
||||
if not org_id:
|
||||
return cls({})
|
||||
return cls(organisations_client.get_organisation(org_id))
|
||||
return cls(organizations_client.get_organization(org_id))
|
||||
|
||||
@classmethod
|
||||
def from_domain(cls, domain):
|
||||
return cls(organisations_client.get_organisation_by_domain(domain))
|
||||
return cls(organizations_client.get_organization_by_domain(domain))
|
||||
|
||||
@classmethod
|
||||
def from_service(cls, service_id):
|
||||
return cls(organisations_client.get_service_organisation(service_id))
|
||||
return cls(organizations_client.get_service_organization(service_id))
|
||||
|
||||
@classmethod
|
||||
def create_from_form(cls, form):
|
||||
return cls.create(
|
||||
name=form.name.data,
|
||||
organisation_type=form.organisation_type.data,
|
||||
organization_type=form.organization_type.data,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def create(cls, name, organisation_type):
|
||||
return cls(organisations_client.create_organisation(
|
||||
def create(cls, name, organization_type):
|
||||
return cls(organizations_client.create_organization(
|
||||
name=name,
|
||||
organisation_type=organisation_type,
|
||||
organization_type=organization_type,
|
||||
))
|
||||
|
||||
def __init__(self, _dict):
|
||||
@@ -75,13 +75,13 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
if self._dict == {}:
|
||||
self.name = None
|
||||
self.domains = []
|
||||
self.organisation_type = None
|
||||
self.organization_type = None
|
||||
self.request_to_go_live_notes = None
|
||||
self.email_branding_id = None
|
||||
|
||||
@property
|
||||
def organisation_type_label(self):
|
||||
return self.TYPE_LABELS.get(self.organisation_type)
|
||||
def organization_type_label(self):
|
||||
return self.TYPE_LABELS.get(self.organization_type)
|
||||
|
||||
@property
|
||||
def billing_details(self):
|
||||
@@ -98,7 +98,7 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
|
||||
@cached_property
|
||||
def services(self):
|
||||
return organisations_client.get_organisation_services(self.id)
|
||||
return organizations_client.get_organization_services(self.id)
|
||||
|
||||
@cached_property
|
||||
def service_ids(self):
|
||||
@@ -114,13 +114,13 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
|
||||
@cached_property
|
||||
def invited_users(self):
|
||||
from app.models.user import OrganisationInvitedUsers
|
||||
return OrganisationInvitedUsers(self.id)
|
||||
from app.models.user import OrganizationInvitedUsers
|
||||
return OrganizationInvitedUsers(self.id)
|
||||
|
||||
@cached_property
|
||||
def active_users(self):
|
||||
from app.models.user import OrganisationUsers
|
||||
return OrganisationUsers(self.id)
|
||||
from app.models.user import OrganizationUsers
|
||||
return OrganizationUsers(self.id)
|
||||
|
||||
@cached_property
|
||||
def team_members(self):
|
||||
@@ -143,7 +143,7 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
return 'GOV.UK'
|
||||
|
||||
def update(self, delete_services_cache=False, **kwargs):
|
||||
response = organisations_client.update_organisation(
|
||||
response = organizations_client.update_organization(
|
||||
self.id,
|
||||
cached_service_ids=self.service_ids if delete_services_cache else None,
|
||||
**kwargs
|
||||
@@ -151,18 +151,18 @@ class Organisation(JSONModel, SortByNameMixin):
|
||||
self.__init__(response)
|
||||
|
||||
def associate_service(self, service_id):
|
||||
organisations_client.update_service_organisation(
|
||||
organizations_client.update_service_organization(
|
||||
service_id,
|
||||
self.id
|
||||
)
|
||||
|
||||
def services_and_usage(self, financial_year):
|
||||
return organisations_client.get_services_and_usage(self.id, financial_year)
|
||||
return organizations_client.get_services_and_usage(self.id, financial_year)
|
||||
|
||||
|
||||
class Organisations(SerialisedModelCollection):
|
||||
model = Organisation
|
||||
class Organizations(SerialisedModelCollection):
|
||||
model = Organization
|
||||
|
||||
|
||||
class AllOrganisations(ModelList, Organisations):
|
||||
client_method = organisations_client.get_organisations
|
||||
class AllOrganizations(ModelList, Organizations):
|
||||
client_method = organizations_client.get_organizations
|
||||
@@ -9,7 +9,7 @@ from app.models.job import (
|
||||
PaginatedUploads,
|
||||
ScheduledJobs,
|
||||
)
|
||||
from app.models.organisation import Organisation
|
||||
from app.models.organization import Organization
|
||||
from app.models.user import InvitedUsers, User, Users
|
||||
from app.notify_client.api_key_api_client import api_key_api_client
|
||||
from app.notify_client.billing_api_client import billing_api_client
|
||||
@@ -17,7 +17,7 @@ from app.notify_client.email_branding_client import email_branding_client
|
||||
from app.notify_client.inbound_number_client import inbound_number_client
|
||||
from app.notify_client.invite_api_client import invite_api_client
|
||||
from app.notify_client.job_api_client import job_api_client
|
||||
from app.notify_client.organisations_api_client import organisations_client
|
||||
from app.notify_client.organizations_api_client import organizations_client
|
||||
from app.notify_client.service_api_client import service_api_client
|
||||
from app.notify_client.template_folder_api_client import (
|
||||
template_folder_api_client,
|
||||
@@ -314,7 +314,7 @@ class Service(JSONModel, SortByNameMixin):
|
||||
|
||||
@property
|
||||
def shouldnt_use_govuk_as_sms_sender(self):
|
||||
return self.organisation_type != Organisation.TYPE_CENTRAL
|
||||
return self.organization_type != Organization.TYPE_CENTRAL
|
||||
|
||||
@cached_property
|
||||
def sms_senders(self):
|
||||
@@ -417,29 +417,29 @@ class Service(JSONModel, SortByNameMixin):
|
||||
|
||||
@property
|
||||
def needs_to_change_email_branding(self):
|
||||
return self.email_branding_id is None and self.organisation_type != Organisation.TYPE_CENTRAL
|
||||
return self.email_branding_id is None and self.organization_type != Organization.TYPE_CENTRAL
|
||||
|
||||
@cached_property
|
||||
def organisation(self):
|
||||
return Organisation.from_id(self.organisation_id)
|
||||
def organization(self):
|
||||
return Organization.from_id(self.organization_id)
|
||||
|
||||
@property
|
||||
def organisation_id(self):
|
||||
return self._dict['organisation']
|
||||
def organization_id(self):
|
||||
return self._dict['organization']
|
||||
|
||||
@property
|
||||
def organisation_type(self):
|
||||
return self.organisation.organisation_type or self._dict['organisation_type']
|
||||
def organization_type(self):
|
||||
return self.organization.organization_type or self._dict['organization_type']
|
||||
|
||||
@property
|
||||
def organisation_name(self):
|
||||
if not self.organisation_id:
|
||||
def organization_name(self):
|
||||
if not self.organization_id:
|
||||
return None
|
||||
return organisations_client.get_organisation_name(self.organisation_id)
|
||||
return organizations_client.get_organization_name(self.organization_id)
|
||||
|
||||
@property
|
||||
def organisation_type_label(self):
|
||||
return Organisation.TYPE_LABELS.get(self.organisation_type)
|
||||
def organization_type_label(self):
|
||||
return Organization.TYPE_LABELS.get(self.organization_type)
|
||||
|
||||
@cached_property
|
||||
def inbound_number(self):
|
||||
|
||||
@@ -10,7 +10,7 @@ from app.event_handlers import (
|
||||
create_set_user_permissions_event,
|
||||
)
|
||||
from app.models import JSONModel, ModelList
|
||||
from app.models.organisation import Organisation, Organisations
|
||||
from app.models.organization import Organization, Organizations
|
||||
from app.models.webauthn_credential import WebAuthnCredentials
|
||||
from app.notify_client import InviteTokenError
|
||||
from app.notify_client.invite_api_client import invite_api_client
|
||||
@@ -223,7 +223,7 @@ class User(JSONModel, UserMixin):
|
||||
org_id = _get_org_id_from_view_args()
|
||||
|
||||
if not service_id and not org_id:
|
||||
# we shouldn't have any pages that require permissions, but don't specify a service or organisation.
|
||||
# we shouldn't have any pages that require permissions, but don't specify a service or organization.
|
||||
# use @user_is_platform_admin for platform admin only pages
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -234,7 +234,7 @@ class User(JSONModel, UserMixin):
|
||||
return True
|
||||
|
||||
if org_id:
|
||||
value = self.belongs_to_organisation(org_id)
|
||||
value = self.belongs_to_organization(org_id)
|
||||
current_app.logger.warn(f"{log_msg} org: {org_id} returning {value}")
|
||||
return value
|
||||
|
||||
@@ -250,8 +250,8 @@ class User(JSONModel, UserMixin):
|
||||
|
||||
from app.models.service import Service
|
||||
|
||||
org_value = allow_org_user and self.belongs_to_organisation(
|
||||
Service.from_id(service_id).organisation_id
|
||||
org_value = allow_org_user and self.belongs_to_organization(
|
||||
Service.from_id(service_id).organization_id
|
||||
)
|
||||
current_app.logger.warn(f"{log_msg} returning {org_value}")
|
||||
return org_value
|
||||
@@ -294,8 +294,8 @@ class User(JSONModel, UserMixin):
|
||||
if not self.belongs_to_service(service_id):
|
||||
abort(403)
|
||||
|
||||
def belongs_to_organisation(self, organisation_id):
|
||||
return str(organisation_id) in self.organisation_ids
|
||||
def belongs_to_organization(self, organization_id):
|
||||
return str(organization_id) in self.organization_ids
|
||||
|
||||
@property
|
||||
def locked(self):
|
||||
@@ -307,7 +307,7 @@ class User(JSONModel, UserMixin):
|
||||
|
||||
@cached_property
|
||||
def orgs_and_services(self):
|
||||
return user_api_client.get_organisations_and_services_for_user(self.id)
|
||||
return user_api_client.get_organizations_and_services_for_user(self.id)
|
||||
|
||||
@property
|
||||
def services(self):
|
||||
@@ -315,10 +315,10 @@ class User(JSONModel, UserMixin):
|
||||
return Services(self.orgs_and_services['services'])
|
||||
|
||||
@property
|
||||
def services_with_organisation(self):
|
||||
def services_with_organization(self):
|
||||
return [
|
||||
service for service in self.services
|
||||
if self.belongs_to_organisation(service.organisation_id)
|
||||
if self.belongs_to_organization(service.organization_id)
|
||||
]
|
||||
|
||||
@property
|
||||
@@ -338,21 +338,21 @@ class User(JSONModel, UserMixin):
|
||||
]
|
||||
|
||||
@property
|
||||
def organisations(self):
|
||||
return Organisations(self.orgs_and_services['organisations'])
|
||||
def organizations(self):
|
||||
return Organizations(self.orgs_and_services['organizations'])
|
||||
|
||||
@property
|
||||
def organisation_ids(self):
|
||||
return self._dict['organisations']
|
||||
def organization_ids(self):
|
||||
return self._dict['organizations']
|
||||
|
||||
@cached_property
|
||||
def default_organisation(self):
|
||||
return Organisation.from_domain(self.email_domain)
|
||||
def default_organization(self):
|
||||
return Organization.from_domain(self.email_domain)
|
||||
|
||||
@property
|
||||
def default_organisation_type(self):
|
||||
if self.default_organisation:
|
||||
return self.default_organisation.organisation_type
|
||||
def default_organization_type(self):
|
||||
if self.default_organization:
|
||||
return self.default_organization.organization_type
|
||||
if self.has_nhs_email_address:
|
||||
return 'nhs'
|
||||
return None
|
||||
@@ -360,7 +360,7 @@ class User(JSONModel, UserMixin):
|
||||
@property
|
||||
def has_access_to_live_and_trial_mode_services(self):
|
||||
return (
|
||||
self.organisations or self.live_services
|
||||
self.organizations or self.live_services
|
||||
) and (
|
||||
self.trial_mode_services
|
||||
)
|
||||
@@ -390,7 +390,7 @@ class User(JSONModel, UserMixin):
|
||||
"state": self.state,
|
||||
"failed_login_count": self.failed_login_count,
|
||||
"permissions": [x for x in self._permissions],
|
||||
"organisations": self.organisation_ids,
|
||||
"organizations": self.organization_ids,
|
||||
"current_session_id": self.current_session_id
|
||||
}
|
||||
if hasattr(self, '_password'):
|
||||
@@ -450,9 +450,9 @@ class User(JSONModel, UserMixin):
|
||||
else:
|
||||
raise exception
|
||||
|
||||
def add_to_organisation(self, organisation_id):
|
||||
user_api_client.add_user_to_organisation(
|
||||
organisation_id,
|
||||
def add_to_organization(self, organization_id):
|
||||
user_api_client.add_user_to_organization(
|
||||
organization_id,
|
||||
self.id,
|
||||
)
|
||||
|
||||
@@ -611,7 +611,7 @@ class InvitedOrgUser(JSONModel):
|
||||
|
||||
ALLOWED_PROPERTIES = {
|
||||
'id',
|
||||
'organisation',
|
||||
'organization',
|
||||
'email_address',
|
||||
'status',
|
||||
'created_at',
|
||||
@@ -623,11 +623,11 @@ class InvitedOrgUser(JSONModel):
|
||||
|
||||
def __eq__(self, other):
|
||||
return ((self.id,
|
||||
self.organisation,
|
||||
self.organization,
|
||||
self._invited_by,
|
||||
self.email_address,
|
||||
self.status) == (other.id,
|
||||
other.organisation,
|
||||
other.organization,
|
||||
other._invited_by,
|
||||
other.email_address,
|
||||
other.status))
|
||||
@@ -657,7 +657,7 @@ class InvitedOrgUser(JSONModel):
|
||||
|
||||
def serialize(self, permissions_as_string=False):
|
||||
data = {'id': self.id,
|
||||
'organisation': self.organisation,
|
||||
'organization': self.organization,
|
||||
'invited_by': self._invited_by,
|
||||
'email_address': self.email_address,
|
||||
'status': self.status,
|
||||
@@ -680,7 +680,7 @@ class InvitedOrgUser(JSONModel):
|
||||
raise exception
|
||||
|
||||
def accept_invite(self):
|
||||
org_invite_api_client.accept_invite(self.organisation, self.id)
|
||||
org_invite_api_client.accept_invite(self.organization, self.id)
|
||||
|
||||
|
||||
class AnonymousUser(AnonymousUserMixin):
|
||||
@@ -690,8 +690,8 @@ class AnonymousUser(AnonymousUserMixin):
|
||||
return False
|
||||
|
||||
@property
|
||||
def default_organisation(self):
|
||||
return Organisation(None)
|
||||
def default_organization(self):
|
||||
return Organization(None)
|
||||
|
||||
|
||||
class Users(ModelList):
|
||||
@@ -712,8 +712,8 @@ class Users(ModelList):
|
||||
return 'Unknown'
|
||||
|
||||
|
||||
class OrganisationUsers(Users):
|
||||
client_method = user_api_client.get_users_for_organisation
|
||||
class OrganizationUsers(Users):
|
||||
client_method = user_api_client.get_users_for_organization
|
||||
|
||||
|
||||
class InvitedUsers(Users):
|
||||
@@ -728,6 +728,6 @@ class InvitedUsers(Users):
|
||||
]
|
||||
|
||||
|
||||
class OrganisationInvitedUsers(InvitedUsers):
|
||||
client_method = org_invite_api_client.get_invites_for_organisation
|
||||
class OrganizationInvitedUsers(InvitedUsers):
|
||||
client_method = org_invite_api_client.get_invites_for_organization
|
||||
model = InvitedOrgUser
|
||||
|
||||
Reference in New Issue
Block a user