mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-14 23:44:56 -05:00
Auto populate the phone number when replying
Currently the only way of ‘replying’ to an inbound message is by copy/pasting the phone number from the inbound page into the send one off page. Rather than making people copy/paste, this commit puts the phone number in the session, if the user is going through the new reply flow.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from flask import (
|
||||
jsonify,
|
||||
session,
|
||||
redirect,
|
||||
render_template,
|
||||
url_for,
|
||||
)
|
||||
@@ -60,9 +62,30 @@ def conversation_reply(
|
||||
show_search_box=(len(templates) > 7),
|
||||
template_type='sms',
|
||||
search_form=SearchTemplatesForm(),
|
||||
notification_id=notification_id,
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with/<template_id>")
|
||||
@login_required
|
||||
@user_has_permissions('send_texts', admin_override=True)
|
||||
def conversation_reply_with_template(
|
||||
service_id,
|
||||
notification_id,
|
||||
template_id,
|
||||
):
|
||||
|
||||
session['recipient'] = get_user_number(service_id, notification_id)
|
||||
session['placeholders'] = {'phone number': session['recipient']}
|
||||
|
||||
return redirect(url_for(
|
||||
'main.send_one_off_step',
|
||||
service_id=service_id,
|
||||
template_id=template_id,
|
||||
step_index=1,
|
||||
))
|
||||
|
||||
|
||||
def get_conversation_partials(service_id, user_number):
|
||||
|
||||
return {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
{% for template in templates %}
|
||||
<div class="column-whole">
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
<a href="{{ url_for('.conversation_reply_with_template', service_id=current_service.id, template_id=template.id, notification_id=notification_id) }}">{{ template.name }}</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
|
||||
|
||||
@@ -257,8 +257,32 @@ def test_conversation_reply_shows_templates(
|
||||
assert normalize_spaces(link.text) == expected
|
||||
assert link.select_one('a')['href'].startswith(
|
||||
url_for(
|
||||
'main.view_template',
|
||||
'main.conversation_reply_with_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
template_id='',
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_conversation_reply_redirects_with_phone_number_from_notification(
|
||||
client_request,
|
||||
fake_uuid,
|
||||
mock_get_notification,
|
||||
mock_get_service_template,
|
||||
):
|
||||
|
||||
page = client_request.get(
|
||||
'main.conversation_reply_with_template',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
notification_id=fake_uuid,
|
||||
template_id=fake_uuid,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
|
||||
for element, expected_text in [
|
||||
('h1', 'Preview of Two week reminder'),
|
||||
('.sms-message-recipient', 'To: 07123 456789'),
|
||||
('.sms-message-wrapper', 'service one: Template <em>content</em> with & entity'),
|
||||
]:
|
||||
assert normalize_spaces(page.select_one(element).text) == expected_text
|
||||
|
||||
Reference in New Issue
Block a user