mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-12 13:20:43 -04:00
Merge pull request #965 from GSA/893-copy-existing-template
893 copy existing template
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
{% block maincolumn_content %}
|
||||
|
||||
<div class="">
|
||||
<h1 class="font-body-2xl margin-bottom-3">{{ page_title }}</h1>
|
||||
<h1 class="font-body-2xl margin-y-0">{{ page_title }}</h1>
|
||||
{{ copy_folder_path(template_folder_path, current_service.id, from_service, current_user) }}
|
||||
</div>
|
||||
{% if not services_templates_and_folders.templates_to_show %}
|
||||
@@ -28,32 +28,24 @@
|
||||
<nav id="template-list">
|
||||
<ul>
|
||||
{% for item in services_templates_and_folders %}
|
||||
<li class="template-list-item {% if item.ancestors %}template-list-item-hidden-by-default{% endif %} {% if not item.ancestors %}template-list-item-without-ancestors{% endif %}">
|
||||
{% for ancestor in item.ancestors %}
|
||||
{% if ancestor.is_service %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_service=ancestor.service_id) }}" class="usa-link template-list-folder">
|
||||
{% else %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_folder=ancestor.id) }}" class="usa-link template-list-folder">
|
||||
{% endif %}
|
||||
{{ ancestor.name }}
|
||||
</a> <span class="message-name-separator"></span>
|
||||
{% endfor %}
|
||||
|
||||
<li class="template-list-item margin-bottom-2 {% if item.ancestors %}template-list-item-hidden-by-default{% endif %} {% if not item.ancestors %}template-list-item-without-ancestors{% endif %}">
|
||||
{% if item.is_service %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_service=item.service_id) }}" class="usa-link template-list-folder">
|
||||
<span class="live-search-relevant">{{ item.name }}</span>
|
||||
</a>
|
||||
{% elif item.is_folder %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_service=item.service_id, from_folder=item.id) }}" class="usa-link template-list-folder">
|
||||
<span class="live-search-relevant">{{ item.name }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
{% for ancestor in item.ancestors %}
|
||||
{% if ancestor.is_service %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_service=ancestor.service_id) }}" class="usa-link template-list-folder">
|
||||
{% else %}
|
||||
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service.id, from_folder=ancestor.id) }}" class="usa-link template-list-folder">
|
||||
{% endif %}
|
||||
{{ ancestor.name }}
|
||||
</a> <span class="message-name-separator"></span>
|
||||
{% endfor %}
|
||||
<a class="usa-link template-list-template" href="{{ url_for('.copy_template', service_id=current_service.id, template_id=item.id, from_service=item.service_id) }}">
|
||||
<span class="live-search-relevant">{{ item.name }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
<p class="template-list-item-hint usa-hint usa-checkbox__label-description">
|
||||
{{ item.hint }}
|
||||
</p>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -739,16 +739,16 @@ def test_choose_a_template_to_copy(
|
||||
assert page.select(".folder-heading") == []
|
||||
|
||||
expected = [
|
||||
("Service 1 " "4 templates"),
|
||||
("Service 1 sms_template_one " "Text message template"),
|
||||
("Service 1 sms_template_two " "Text message template"),
|
||||
("Service 1 email_template_one " "Email template"),
|
||||
("Service 1 email_template_two " "Email template"),
|
||||
("Service 2 " "4 templates"),
|
||||
("Service 2 sms_template_one " "Text message template"),
|
||||
("Service 2 sms_template_two " "Text message template"),
|
||||
("Service 2 email_template_one " "Email template"),
|
||||
("Service 2 email_template_two " "Email template"),
|
||||
(""),
|
||||
("Service 1 sms_template_one"),
|
||||
("Service 1 sms_template_two"),
|
||||
("Service 1 email_template_one"),
|
||||
("Service 1 email_template_two"),
|
||||
(""),
|
||||
("Service 2 sms_template_one"),
|
||||
("Service 2 sms_template_two"),
|
||||
("Service 2 email_template_one"),
|
||||
("Service 2 email_template_two"),
|
||||
]
|
||||
actual = page.select(".template-list-item")
|
||||
|
||||
@@ -763,17 +763,6 @@ def test_choose_a_template_to_copy(
|
||||
service_id=SERVICE_ONE_ID,
|
||||
from_service=SERVICE_TWO_ID,
|
||||
)
|
||||
assert links[1]["href"] == url_for(
|
||||
"main.choose_template_to_copy",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
from_service=SERVICE_TWO_ID,
|
||||
)
|
||||
assert links[2]["href"] == url_for(
|
||||
"main.copy_template",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=TEMPLATE_ONE_ID,
|
||||
from_service=SERVICE_TWO_ID,
|
||||
)
|
||||
|
||||
|
||||
def test_choose_a_template_to_copy_when_user_has_one_service(
|
||||
@@ -791,10 +780,10 @@ def test_choose_a_template_to_copy_when_user_has_one_service(
|
||||
assert page.select(".folder-heading") == []
|
||||
|
||||
expected = [
|
||||
("sms_template_one " "Text message template"),
|
||||
("sms_template_two " "Text message template"),
|
||||
("email_template_one " "Email template"),
|
||||
("email_template_two " "Email template"),
|
||||
("sms_template_one"),
|
||||
("sms_template_two"),
|
||||
("email_template_one"),
|
||||
("email_template_two"),
|
||||
]
|
||||
actual = page.select(".template-list-item")
|
||||
|
||||
@@ -821,7 +810,7 @@ def test_choose_a_template_to_copy_from_folder_within_service(
|
||||
):
|
||||
mock_get_template_folders.return_value = [
|
||||
_folder("Parent folder", PARENT_FOLDER_ID),
|
||||
_folder("Child folder empty", CHILD_FOLDER_ID, parent=PARENT_FOLDER_ID),
|
||||
_folder("", CHILD_FOLDER_ID, parent=PARENT_FOLDER_ID),
|
||||
_folder("Child folder non-empty", FOLDER_TWO_ID, parent=PARENT_FOLDER_ID),
|
||||
]
|
||||
mocker.patch(
|
||||
@@ -865,13 +854,10 @@ def test_choose_a_template_to_copy_from_folder_within_service(
|
||||
)
|
||||
|
||||
expected = [
|
||||
("Child folder empty " "Empty"),
|
||||
("Child folder non-empty " "1 template"),
|
||||
(
|
||||
"Child folder non-empty Should appear in list (nested) "
|
||||
"Text message template"
|
||||
),
|
||||
("Should appear in list (at same level) " "Text message template"),
|
||||
(""),
|
||||
(""),
|
||||
("Child folder non-empty Should appear in list (nested)"),
|
||||
("Should appear in list (at same level)"),
|
||||
]
|
||||
actual = page.select(".template-list-item")
|
||||
|
||||
@@ -885,26 +871,25 @@ def test_choose_a_template_to_copy_from_folder_within_service(
|
||||
assert links[0]["href"] == url_for(
|
||||
"main.choose_template_to_copy",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
from_service=SERVICE_ONE_ID,
|
||||
from_folder=CHILD_FOLDER_ID,
|
||||
)
|
||||
assert links[1]["href"] == url_for(
|
||||
"main.choose_template_to_copy",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
from_service=SERVICE_ONE_ID,
|
||||
from_folder=FOLDER_TWO_ID,
|
||||
)
|
||||
assert links[2]["href"] == url_for(
|
||||
"main.choose_template_to_copy",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
from_folder=FOLDER_TWO_ID,
|
||||
)
|
||||
assert links[3]["href"] == url_for(
|
||||
"main.copy_template",
|
||||
service_id=SERVICE_ONE_ID,
|
||||
template_id=TEMPLATE_ONE_ID,
|
||||
from_service=SERVICE_ONE_ID,
|
||||
)
|
||||
# assert links[1]["href"] == url_for(
|
||||
# "main.choose_template_to_copy",
|
||||
# service_id=SERVICE_ONE_ID,
|
||||
# from_service=SERVICE_ONE_ID,
|
||||
# from_folder=PARENT_FOLDER_ID,
|
||||
# )
|
||||
# assert links[2]["href"] == url_for(
|
||||
# "main.choose_template_to_copy",
|
||||
# service_id=SERVICE_ONE_ID,
|
||||
# from_folder=FOLDER_TWO_ID,
|
||||
# )
|
||||
# assert links[3]["href"] == url_for(
|
||||
# "main.copy_template",
|
||||
# service_id=SERVICE_ONE_ID,
|
||||
# template_id=TEMPLATE_ONE_ID,
|
||||
# from_service=SERVICE_ONE_ID,
|
||||
# )
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user