2018-04-24 12:48:05 +01:00
|
|
|
from itertools import chain
|
|
|
|
|
|
|
|
|
|
from flask import request
|
|
|
|
|
|
2025-07-15 23:56:58 -07:00
|
|
|
from app.enums import ServicePermission
|
|
|
|
|
|
2018-04-24 12:48:05 +01:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
class Navigation:
|
|
|
|
|
mapping = {}
|
2023-06-08 13:12:00 -04:00
|
|
|
selected_class = "usa-current"
|
2018-04-24 12:48:05 +01:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
def __init__(self):
|
|
|
|
|
self.mapping = {
|
|
|
|
|
navigation: {
|
2019-11-29 11:40:49 +00:00
|
|
|
# if not specified, assume endpoints are all in the `main` blueprint.
|
2023-08-25 09:12:23 -07:00
|
|
|
self.get_endpoint_with_blueprint(endpoint)
|
|
|
|
|
for endpoint in endpoints
|
|
|
|
|
}
|
|
|
|
|
for navigation, endpoints in self.mapping.items()
|
2018-04-25 10:24:32 +01:00
|
|
|
}
|
2018-04-24 12:48:05 +01:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
@property
|
|
|
|
|
def endpoints_with_navigation(self):
|
2023-08-25 09:12:23 -07:00
|
|
|
return tuple(
|
|
|
|
|
chain.from_iterable(
|
|
|
|
|
(endpoints for navigation_item, endpoints in self.mapping.items())
|
|
|
|
|
)
|
|
|
|
|
)
|
2018-04-24 12:48:05 +01:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
def is_selected(self, navigation_item):
|
|
|
|
|
if request.endpoint in self.mapping[navigation_item]:
|
2023-06-08 13:12:00 -04:00
|
|
|
return self.selected_class
|
2023-08-25 09:12:23 -07:00
|
|
|
return ""
|
2018-04-25 10:24:32 +01:00
|
|
|
|
2019-11-29 11:40:49 +00:00
|
|
|
@staticmethod
|
2021-02-26 18:19:47 +00:00
|
|
|
def get_endpoint_with_blueprint(endpoint):
|
2023-08-25 09:12:23 -07:00
|
|
|
return endpoint if "." in endpoint else "main.{}".format(endpoint)
|
2019-11-29 11:40:49 +00:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
|
2018-04-25 11:11:37 +01:00
|
|
|
class HeaderNavigation(Navigation):
|
|
|
|
|
mapping = {
|
2023-08-25 09:12:23 -07:00
|
|
|
"support": {
|
|
|
|
|
"support",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
2024-11-13 10:01:33 -05:00
|
|
|
"best_practices": {
|
|
|
|
|
"best_practices",
|
2024-11-13 10:30:06 -05:00
|
|
|
"clear_goals",
|
|
|
|
|
"rules_and_regulations",
|
|
|
|
|
"establish_trust",
|
|
|
|
|
"write_for_action",
|
|
|
|
|
"multiple_languages",
|
2024-11-21 15:08:49 -08:00
|
|
|
"benchmark_performance",
|
2024-11-04 11:44:45 -05:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"using_notify": {
|
|
|
|
|
"get_started",
|
|
|
|
|
"pricing",
|
|
|
|
|
"trial_mode_new",
|
|
|
|
|
"message_status",
|
2025-01-22 10:41:29 -08:00
|
|
|
"how_to",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
2023-10-12 10:21:11 -04:00
|
|
|
"accounts-or-dashboard": {
|
2023-10-12 13:52:03 -04:00
|
|
|
"conversation",
|
|
|
|
|
"service_dashboard",
|
|
|
|
|
"template_usage",
|
|
|
|
|
"view_notification",
|
|
|
|
|
"action_blocked",
|
|
|
|
|
"add_service_template",
|
|
|
|
|
"check_messages",
|
|
|
|
|
"check_notification",
|
|
|
|
|
"choose_template",
|
|
|
|
|
"choose_template_to_copy",
|
|
|
|
|
"confirm_redact_template",
|
|
|
|
|
"conversation_reply",
|
|
|
|
|
"copy_template",
|
|
|
|
|
"delete_service_template",
|
|
|
|
|
"edit_service_template",
|
|
|
|
|
"manage_template_folder",
|
2025-07-15 23:56:58 -07:00
|
|
|
ServicePermission.SEND_MESSAGES,
|
2023-10-12 13:52:03 -04:00
|
|
|
"send_one_off",
|
|
|
|
|
"send_one_off_step",
|
|
|
|
|
"send_one_off_to_myself",
|
|
|
|
|
"set_sender",
|
|
|
|
|
"set_template_sender",
|
|
|
|
|
"view_template",
|
|
|
|
|
"view_template_version",
|
|
|
|
|
"view_template_versions",
|
|
|
|
|
"uploads",
|
|
|
|
|
"view_job",
|
|
|
|
|
"view_jobs",
|
2023-10-12 13:40:41 -04:00
|
|
|
"usage",
|
2023-10-12 10:21:11 -04:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"documentation": {
|
|
|
|
|
"documentation",
|
|
|
|
|
"integration_testing",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"user-profile": {
|
|
|
|
|
"user_profile",
|
|
|
|
|
"user_profile_confirm_delete_mobile_number",
|
|
|
|
|
"user_profile_email",
|
|
|
|
|
"user_profile_email_authenticate",
|
|
|
|
|
"user_profile_email_confirm",
|
|
|
|
|
"user_profile_mobile_number",
|
|
|
|
|
"user_profile_mobile_number_authenticate",
|
|
|
|
|
"user_profile_mobile_number_confirm",
|
|
|
|
|
"user_profile_mobile_number_delete",
|
|
|
|
|
"user_profile_name",
|
|
|
|
|
"user_profile_password",
|
2023-11-30 12:39:37 -08:00
|
|
|
"user_profile_preferred_timezone",
|
2023-08-25 09:12:23 -07:00
|
|
|
"user_profile_disable_platform_admin_view",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"platform-admin": {
|
|
|
|
|
"archive_user",
|
|
|
|
|
"change_user_auth",
|
|
|
|
|
"clear_cache",
|
|
|
|
|
"find_services_by_name",
|
|
|
|
|
"find_users_by_email",
|
|
|
|
|
"live_services",
|
|
|
|
|
"live_services_csv",
|
|
|
|
|
"notifications_sent_by_service",
|
|
|
|
|
"get_billing_report",
|
|
|
|
|
"get_users_report",
|
|
|
|
|
"get_daily_volumes",
|
2024-08-06 11:31:05 -07:00
|
|
|
"download_all_users",
|
2023-08-25 09:12:23 -07:00
|
|
|
"get_daily_sms_provider_volumes",
|
|
|
|
|
"get_volumes_by_service",
|
|
|
|
|
"organizations",
|
|
|
|
|
"platform_admin",
|
|
|
|
|
"platform_admin_list_complaints",
|
|
|
|
|
"platform_admin_reports",
|
|
|
|
|
"platform_admin_splash_page",
|
|
|
|
|
"suspend_service",
|
|
|
|
|
"trial_services",
|
|
|
|
|
"user_information",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"sign-in": {
|
|
|
|
|
"revalidate_email_sent",
|
|
|
|
|
"sign_in",
|
|
|
|
|
"two_factor_sms",
|
|
|
|
|
"two_factor_email",
|
|
|
|
|
"two_factor_email_sent",
|
|
|
|
|
"two_factor_email_interstitial",
|
|
|
|
|
"verify",
|
|
|
|
|
"verify_email",
|
2018-04-25 11:11:37 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-06 09:38:54 -04:00
|
|
|
# header HTML now comes from USWDS so requires a boolean, not an attribute
|
2019-10-09 16:00:45 +01:00
|
|
|
def is_selected(self, navigation_item):
|
2019-10-30 10:17:32 +00:00
|
|
|
return request.endpoint in self.mapping[navigation_item]
|
2019-10-09 16:00:45 +01:00
|
|
|
|
2018-04-25 11:11:37 +01:00
|
|
|
|
2018-04-25 10:24:32 +01:00
|
|
|
class MainNavigation(Navigation):
|
|
|
|
|
mapping = {
|
2024-07-18 15:57:29 -07:00
|
|
|
"activity": {
|
|
|
|
|
"all_jobs_activity",
|
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"dashboard": {
|
|
|
|
|
"conversation",
|
|
|
|
|
"service_dashboard",
|
|
|
|
|
"template_usage",
|
|
|
|
|
"view_notification",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"templates": {
|
|
|
|
|
"action_blocked",
|
|
|
|
|
"add_service_template",
|
|
|
|
|
"check_messages",
|
|
|
|
|
"check_notification",
|
|
|
|
|
"choose_template",
|
|
|
|
|
"choose_template_to_copy",
|
|
|
|
|
"confirm_redact_template",
|
|
|
|
|
"conversation_reply",
|
|
|
|
|
"copy_template",
|
|
|
|
|
"delete_service_template",
|
|
|
|
|
"edit_service_template",
|
|
|
|
|
"manage_template_folder",
|
2025-07-15 23:56:58 -07:00
|
|
|
ServicePermission.SEND_MESSAGES,
|
2023-08-25 09:12:23 -07:00
|
|
|
"send_one_off",
|
|
|
|
|
"send_one_off_step",
|
|
|
|
|
"send_one_off_to_myself",
|
|
|
|
|
"set_sender",
|
|
|
|
|
"set_template_sender",
|
|
|
|
|
"view_template",
|
|
|
|
|
"view_template_version",
|
|
|
|
|
"view_template_versions",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"uploads": {
|
|
|
|
|
"uploads",
|
|
|
|
|
"view_job",
|
|
|
|
|
"view_jobs",
|
2019-08-09 08:44:11 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"team-members": {
|
|
|
|
|
"confirm_edit_user_email",
|
|
|
|
|
"confirm_edit_user_mobile_number",
|
|
|
|
|
"edit_user_email",
|
|
|
|
|
"edit_user_mobile_number",
|
|
|
|
|
"edit_user_permissions",
|
|
|
|
|
"invite_user",
|
|
|
|
|
"manage_users",
|
|
|
|
|
"remove_user_from_service",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"usage": {
|
|
|
|
|
"usage",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
2024-01-03 13:51:11 -05:00
|
|
|
"user-profile": {
|
|
|
|
|
"user_profile",
|
|
|
|
|
"user_profile_confirm_delete_mobile_number",
|
|
|
|
|
"user_profile_email",
|
|
|
|
|
"user_profile_email_authenticate",
|
|
|
|
|
"user_profile_email_confirm",
|
|
|
|
|
"user_profile_mobile_number",
|
|
|
|
|
"user_profile_mobile_number_authenticate",
|
|
|
|
|
"user_profile_mobile_number_confirm",
|
|
|
|
|
"user_profile_mobile_number_delete",
|
|
|
|
|
"user_profile_name",
|
|
|
|
|
"user_profile_password",
|
|
|
|
|
"user_profile_preferred_timezone",
|
|
|
|
|
"user_profile_disable_platform_admin_view",
|
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"settings": {
|
|
|
|
|
"link_service_to_organization",
|
|
|
|
|
"service_add_email_reply_to",
|
|
|
|
|
"service_add_sms_sender",
|
|
|
|
|
"service_confirm_delete_email_reply_to",
|
|
|
|
|
"service_confirm_delete_sms_sender",
|
|
|
|
|
"service_edit_email_reply_to",
|
|
|
|
|
"service_edit_sms_sender",
|
|
|
|
|
"service_email_reply_to",
|
|
|
|
|
"service_name_change",
|
|
|
|
|
"service_set_auth_type",
|
|
|
|
|
"service_set_channel",
|
|
|
|
|
"send_files_by_email_contact_details",
|
|
|
|
|
"service_set_inbound_number",
|
|
|
|
|
"service_set_inbound_sms",
|
|
|
|
|
"service_set_international_sms",
|
|
|
|
|
"service_set_reply_to_email",
|
|
|
|
|
"service_set_sms_prefix",
|
|
|
|
|
"service_verify_reply_to_address",
|
|
|
|
|
"service_verify_reply_to_address_updates",
|
|
|
|
|
"service_settings",
|
|
|
|
|
"service_sms_senders",
|
|
|
|
|
"set_free_sms_allowance",
|
|
|
|
|
"set_message_limit",
|
|
|
|
|
"set_rate_limit",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"api-integration": {
|
|
|
|
|
"api_callbacks",
|
|
|
|
|
"api_documentation",
|
|
|
|
|
"api_integration",
|
|
|
|
|
"api_keys",
|
|
|
|
|
"create_api_key",
|
|
|
|
|
"delivery_status_callback",
|
|
|
|
|
"received_text_messages_callback",
|
|
|
|
|
"revoke_api_key",
|
|
|
|
|
"guest_list",
|
|
|
|
|
"old_guest_list",
|
2018-04-25 10:24:32 +01:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-25 13:17:47 +01:00
|
|
|
|
2018-06-12 16:17:20 +01:00
|
|
|
class CaseworkNavigation(Navigation):
|
|
|
|
|
mapping = {
|
2023-08-25 09:12:23 -07:00
|
|
|
"send-one-off": {
|
|
|
|
|
"choose_template",
|
|
|
|
|
"send_one_off",
|
|
|
|
|
"send_one_off_step",
|
|
|
|
|
"send_one_off_to_myself",
|
2018-06-13 14:16:10 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"sent-messages": {
|
|
|
|
|
"view_notification",
|
2018-06-12 16:17:20 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"uploads": {
|
|
|
|
|
"view_jobs",
|
|
|
|
|
"view_job",
|
|
|
|
|
"uploads",
|
2018-07-30 17:40:32 +01:00
|
|
|
},
|
2018-06-12 16:17:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-01-03 13:51:11 -05:00
|
|
|
class SecondaryNavigation(Navigation):
|
|
|
|
|
mapping = {
|
|
|
|
|
"settings": {
|
|
|
|
|
"link_service_to_organization",
|
|
|
|
|
"service_add_email_reply_to",
|
|
|
|
|
"service_add_sms_sender",
|
|
|
|
|
"service_confirm_delete_email_reply_to",
|
|
|
|
|
"service_confirm_delete_sms_sender",
|
|
|
|
|
"service_edit_email_reply_to",
|
|
|
|
|
"service_edit_sms_sender",
|
|
|
|
|
"service_email_reply_to",
|
|
|
|
|
"service_name_change",
|
|
|
|
|
"service_set_auth_type",
|
|
|
|
|
"service_set_channel",
|
|
|
|
|
"send_files_by_email_contact_details",
|
|
|
|
|
"service_set_inbound_number",
|
|
|
|
|
"service_set_inbound_sms",
|
|
|
|
|
"service_set_international_sms",
|
|
|
|
|
"service_set_reply_to_email",
|
|
|
|
|
"service_set_sms_prefix",
|
|
|
|
|
"service_verify_reply_to_address",
|
|
|
|
|
"service_verify_reply_to_address_updates",
|
|
|
|
|
"service_settings",
|
|
|
|
|
"service_sms_senders",
|
|
|
|
|
"set_free_sms_allowance",
|
|
|
|
|
"set_message_limit",
|
|
|
|
|
"set_rate_limit",
|
|
|
|
|
"confirm_edit_user_email",
|
|
|
|
|
"confirm_edit_user_mobile_number",
|
|
|
|
|
"edit_user_email",
|
|
|
|
|
"edit_user_mobile_number",
|
|
|
|
|
"edit_user_permissions",
|
|
|
|
|
"invite_user",
|
|
|
|
|
"manage_users",
|
|
|
|
|
"remove_user_from_service",
|
|
|
|
|
"user_profile",
|
|
|
|
|
"user_profile_confirm_delete_mobile_number",
|
|
|
|
|
"user_profile_email",
|
|
|
|
|
"user_profile_email_authenticate",
|
|
|
|
|
"user_profile_email_confirm",
|
|
|
|
|
"user_profile_mobile_number",
|
|
|
|
|
"user_profile_mobile_number_authenticate",
|
|
|
|
|
"user_profile_mobile_number_confirm",
|
|
|
|
|
"user_profile_mobile_number_delete",
|
|
|
|
|
"user_profile_name",
|
|
|
|
|
"user_profile_password",
|
|
|
|
|
"user_profile_preferred_timezone",
|
|
|
|
|
"user_profile_disable_platform_admin_view",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-04-25 13:17:47 +01:00
|
|
|
class OrgNavigation(Navigation):
|
|
|
|
|
mapping = {
|
2023-08-25 09:12:23 -07:00
|
|
|
"dashboard": {
|
|
|
|
|
"organization_dashboard",
|
2018-04-25 13:17:47 +01:00
|
|
|
},
|
2025-10-14 12:27:15 -07:00
|
|
|
"usage": {
|
|
|
|
|
"organization_usage",
|
|
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"settings": {
|
|
|
|
|
"edit_organization_billing_details",
|
|
|
|
|
"edit_organization_domains",
|
|
|
|
|
"edit_organization_name",
|
|
|
|
|
"edit_organization_notes",
|
|
|
|
|
"edit_organization_type",
|
|
|
|
|
"organization_settings",
|
2018-04-25 13:17:47 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"team-members": {
|
|
|
|
|
"edit_organization_user",
|
|
|
|
|
"invite_org_user",
|
|
|
|
|
"manage_org_users",
|
|
|
|
|
"remove_user_from_organization",
|
2019-05-21 14:56:15 +01:00
|
|
|
},
|
2023-08-25 09:12:23 -07:00
|
|
|
"trial-services": {
|
|
|
|
|
"organization_trial_mode_services",
|
|
|
|
|
},
|
|
|
|
|
"billing": {
|
|
|
|
|
"organization_billing",
|
Add new 'Billing' page for organisations
We want organisation team members to be able to see the MOU details for
their organisation. This change creates a new page called billing, which
contains these details. It's only visible to platform admin users now -
the plan is to add more information to this page, then to make it visible
to all organisation users.
The page showing the MOU covers the case of when agreement_signed is
True, when an agreement_signed is False, and when agreement_signed is
None. The case when an agreement_signed is None is very rare - it
signifies that the agreement is not signed but that we have some
service-specific agreements in place. We only have a few organisations
in this state, so it's unlikely that the content for this scenario will
be seen.
When an organisation has signed the agreement we may know the full
details (signing date, version signed, the person who signed it or who it
was signed on behalf of), or we may only have the name of the person who
signed the agreement. We show the more detailed content if possible, and
a less detailed version of the content if not.
There's a new route for downloading the agreement which is almost
identical to the existing `.service_download_agreement` route (plus the
test is almost the same), except that it takes an organisation ID
instead of a service ID.
2021-12-07 13:42:44 +00:00
|
|
|
},
|
2018-04-25 13:17:47 +01:00
|
|
|
}
|