mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 17:59:45 -04:00
Look at other services only if no templates
This saves one call to the API or Redis in the common case where the current service does have templates. This is because `any()` evaluates all expressions before running, whereas `or` will only evaluate the second expression if the first returns `False`-y.
This commit is contained in:
@@ -258,10 +258,10 @@ def add_template_by_type(service_id, template_folder_id=None):
|
||||
|
||||
form = ChooseTemplateType(
|
||||
include_letters=current_service.has_permission('letter'),
|
||||
include_copy=any((
|
||||
len(current_service.all_templates) > 0,
|
||||
len(user_api_client.get_service_ids_for_user(current_user)) > 1,
|
||||
)),
|
||||
include_copy=(
|
||||
current_service.all_templates or
|
||||
len(user_api_client.get_service_ids_for_user(current_user)) > 1
|
||||
),
|
||||
include_folder=current_service.has_permission('edit_folders')
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user