mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 15:57:23 -04:00
Merge pull request #3043 from alphagov/add-first-letter-contact-experience
Make adding a ‘letter contact block’ for the first time make sense
This commit is contained in:
@@ -706,21 +706,32 @@ def service_letter_contact_details(service_id):
|
||||
def service_add_letter_contact(service_id):
|
||||
form = ServiceLetterContactBlockForm()
|
||||
first_contact_block = current_service.count_letter_contact_details == 0
|
||||
from_template = request.args.get('from_template')
|
||||
if form.validate_on_submit():
|
||||
service_api_client.add_letter_contact(
|
||||
new_letter_contact = service_api_client.add_letter_contact(
|
||||
current_service.id,
|
||||
contact_block=form.letter_contact_block.data.replace('\r', '') or None,
|
||||
is_default=first_contact_block if first_contact_block else form.is_default.data
|
||||
)
|
||||
if request.args.get('from_template'):
|
||||
if from_template:
|
||||
service_api_client.update_service_template_sender(
|
||||
service_id,
|
||||
from_template,
|
||||
new_letter_contact['data']['id'],
|
||||
)
|
||||
return redirect(
|
||||
url_for('.set_template_sender', service_id=service_id, template_id=request.args.get('from_template'))
|
||||
url_for('.view_template', service_id=service_id, template_id=from_template)
|
||||
)
|
||||
return redirect(url_for('.service_letter_contact_details', service_id=service_id))
|
||||
return render_template(
|
||||
'views/service-settings/letter-contact/add.html',
|
||||
form=form,
|
||||
first_contact_block=first_contact_block,
|
||||
back_link=(
|
||||
url_for('main.view_template', template_id=from_template, service_id=current_service.id)
|
||||
if from_template
|
||||
else url_for('.service_letter_contact_details', service_id=current_service.id)
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -57,13 +57,7 @@ def view_template(service_id, template_id):
|
||||
return redirect(url_for(
|
||||
'.send_one_off', service_id=service_id, template_id=template_id
|
||||
))
|
||||
if template["template_type"] == "letter":
|
||||
letter_contact_details = service_api_client.get_letter_contacts(service_id)
|
||||
default_letter_contact_block_id = next(
|
||||
(x['id'] for x in letter_contact_details if x['is_default']), None
|
||||
)
|
||||
else:
|
||||
default_letter_contact_block_id = None
|
||||
|
||||
return render_template(
|
||||
'views/templates/template.html',
|
||||
template=get_template(
|
||||
@@ -81,7 +75,6 @@ def view_template(service_id, template_id):
|
||||
),
|
||||
template_postage=template["postage"],
|
||||
user_has_template_permission=user_has_template_permission,
|
||||
default_letter_contact_block_id=default_letter_contact_block_id,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
{{ page_header(
|
||||
'Add a new address',
|
||||
back_link=None if request.args.get('from_template') else url_for('.service_letter_contact_details', service_id=current_service.id)
|
||||
back_link=back_link
|
||||
) }}
|
||||
<div class="grid-row">
|
||||
<div class="column-whole">
|
||||
|
||||
@@ -49,7 +49,11 @@
|
||||
{% endif %}
|
||||
<a href="{{ url_for(".edit_template_postage", service_id=current_service.id, template_id=template.id) }}" class="edit-template-link-letter-postage">Change</a>
|
||||
<a href="{{ url_for(".edit_service_template", service_id=current_service.id, template_id=template.id) }}" class="edit-template-link-letter-body">Edit</a>
|
||||
<a href="{{ url_for(".set_template_sender", service_id=current_service.id, template_id=template.id) }}" class="edit-template-link-letter-contact">Edit</a>
|
||||
{% if current_service.count_letter_contact_details %}
|
||||
<a href="{{ url_for(".set_template_sender", service_id=current_service.id, template_id=template.id) }}" class="edit-template-link-letter-contact">Edit</a>
|
||||
{% else %}
|
||||
<a href="{{ url_for(".service_add_letter_contact", service_id=current_service.id, from_template=template.id) }}" class="edit-template-link-letter-contact">Edit</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{{ template|string }}
|
||||
</div>
|
||||
|
||||
@@ -23,9 +23,7 @@
|
||||
hide_legend=True
|
||||
) }}
|
||||
{{ page_footer('Continue') }}
|
||||
{% if no_senders %}
|
||||
<a href="{{ url_for('.service_add_letter_contact', service_id=current_service.id, from_template=template_id) }}">Add new sender</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('.service_add_letter_contact', service_id=current_service.id, from_template=template_id) }}">Add new sender</a>
|
||||
{% endcall %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user