diff --git a/app/main/views/choose_account.py b/app/main/views/choose_account.py index e61ca6ee1..e396ce040 100644 --- a/app/main/views/choose_account.py +++ b/app/main/views/choose_account.py @@ -31,17 +31,17 @@ def show_accounts_or_dashboard(): return redirect(url_for('.index')) service_id = session.get('service_id') - if service_id and (service_id in current_user.services or current_user.platform_admin): + if service_id and (service_id in current_user.service_ids or current_user.platform_admin): return redirect(url_for('.service_dashboard', service_id=service_id)) organisation_id = session.get('organisation_id') if organisation_id and (organisation_id in current_user.organisation_ids or current_user.platform_admin): return redirect(url_for('.organisation_dashboard', org_id=organisation_id)) - if len(current_user.services) == 1 and not current_user.organisation_ids: - return redirect(url_for('.service_dashboard', service_id=current_user.services[0])) + if len(current_user.service_ids) == 1 and not current_user.organisation_ids: + return redirect(url_for('.service_dashboard', service_id=current_user.service_ids[0])) - if len(current_user.organisation_ids) == 1 and not current_user.services: + if len(current_user.organisation_ids) == 1 and not current_user.service_ids: return redirect(url_for('.organisation_dashboard', org_id=current_user.organisation_ids[0])) return redirect(url_for('.choose_account')) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index 1a3cd01ba..62c8ca8a1 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -126,7 +126,7 @@ def choose_template(service_id, template_type='all', template_folder_id=None): template_type=template_type, allow_adding_letter_template=current_service.has_permission('letter'), allow_adding_copy_of_template=( - current_service.all_templates or len(current_user.services) > 1 + current_service.all_templates or len(current_user.service_ids) > 1 ), ) option_hints = {template_folder_id: 'current folder'} @@ -369,7 +369,7 @@ def choose_template_to_copy( 'views/templates/copy.html', services_templates_and_folders=TemplateLists([ Service(service) for service in - current_user.all_services + current_user.services ], user=current_user), search_form=SearchByNameForm(), ) @@ -401,7 +401,7 @@ def copy_template(service_id, template_id): form=form, template=template, heading_action='Add', - services=current_user.all_service_ids, + services=current_user.service_ids, ) diff --git a/app/models/user.py b/app/models/user.py index ace1b2e18..9ef7dfa54 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -42,7 +42,6 @@ class User(JSONModel, UserMixin): 'password_changed_at', 'permissions', 'platform_admin', - 'services', 'state', } @@ -195,7 +194,7 @@ class User(JSONModel, UserMixin): if org_id: return org_id in self.organisation_ids if not permissions: - return service_id in self.services + return service_id in self.service_ids if service_id: return any(x in self._permissions.get(service_id, []) for x in permissions) @@ -223,7 +222,7 @@ class User(JSONModel, UserMixin): ] def belongs_to_service(self, service_id): - return str(service_id) in self.services + return str(service_id) in self.service_ids def belongs_to_service_or_403(self, service_id): if not self.belongs_to_service(service_id): @@ -242,29 +241,27 @@ class User(JSONModel, UserMixin): return user_api_client.get_organisations_and_services_for_user(self.id) @property - def all_services(self): + def services(self): all_services = self.orgs_and_services['services_without_organisations'] + next(chain( org['services'] for org in self.orgs_and_services['organisations'] ), []) return sorted(all_services, key=lambda service: service['name'].lower()) @property - def all_service_ids(self): - return { - service['id'] for service in self.all_services - } + def service_ids(self): + return self._dict['services'] @property def trial_mode_services(self): return [ - service for service in self.all_services + service for service in self.services if service['restricted'] ] @property def live_services(self): return [ - service for service in self.all_services + service for service in self.services if not service['restricted'] ] diff --git a/app/templates/views/find-users/user-information.html b/app/templates/views/find-users/user-information.html index 1e8d8ba9e..eb180ee74 100644 --- a/app/templates/views/find-users/user-information.html +++ b/app/templates/views/find-users/user-information.html @@ -16,7 +16,7 @@

Services