mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Put ‘copy’ at end of new template name
In multiple user research sessions we’ve noticed people edit the auto-generated template name to put something at the end of it. This is fiddly because of the quotes we put around the name: > Copy of ‘Exiting template’ It also means that if they keep our prefix then the template doesn’t sort alongside the one it’s replacing. This commit changes the name of copied templates to better match the behaviour our users are showing. Also adds a bit of auto numbering, just as a nice detail.
This commit is contained in:
@@ -317,7 +317,7 @@ def copy_template(service_id, template_id):
|
||||
return add_service_template(service_id, template['template_type'])
|
||||
|
||||
template['template_content'] = template['content']
|
||||
template['name'] = 'Copy of ‘{}’'.format(template['name'])
|
||||
template['name'] = _get_template_copy_name(template, current_service.all_templates)
|
||||
form = form_objects[template['template_type']](**template)
|
||||
|
||||
return render_template(
|
||||
@@ -329,6 +329,20 @@ def copy_template(service_id, template_id):
|
||||
)
|
||||
|
||||
|
||||
def _get_template_copy_name(template, existing_templates):
|
||||
|
||||
template_names = [existing['name'] for existing in existing_templates]
|
||||
|
||||
for index in reversed(range(1, 10)):
|
||||
if '{} (copy {})'.format(template['name'], index) in template_names:
|
||||
return '{} (copy {})'.format(template['name'], index + 1)
|
||||
|
||||
if '{} (copy)'.format(template['name']) in template_names:
|
||||
return '{} (copy 2)'.format(template['name'])
|
||||
|
||||
return '{} (copy)'.format(template['name'])
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/templates/action-blocked/<notification_type>/<return_to>/<template_id>")
|
||||
@login_required
|
||||
@user_has_permissions('manage_templates')
|
||||
|
||||
Reference in New Issue
Block a user