Merge pull request #2862 from alphagov/show-templates-across-user-folders

When replying to inbound sms show templates in all user's folders
This commit is contained in:
Pea (Malgorzata Tyczynska)
2019-03-22 14:15:13 +00:00
committed by GitHub
5 changed files with 105 additions and 52 deletions

View File

@@ -1,5 +1,5 @@
from flask import jsonify, redirect, render_template, session, url_for
from flask_login import login_required
from flask_login import current_user, login_required
from notifications_python_client.errors import HTTPError
from notifications_utils.recipients import format_phone_number_human_readable
from notifications_utils.template import SMSPreviewTemplate
@@ -7,6 +7,7 @@ from notifications_utils.template import SMSPreviewTemplate
from app import current_service, notification_api_client, service_api_client
from app.main import main
from app.main.forms import SearchByNameForm
from app.models.template_list import TemplateList
from app.utils import user_has_permissions
@@ -38,20 +39,26 @@ def conversation_updates(service_id, notification_id):
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with")
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with/from-folder/<uuid:from_folder>")
@login_required
@user_has_permissions('send_messages')
def conversation_reply(
service_id,
notification_id,
from_folder=None,
):
templates = current_service.get_templates('sms')
return render_template(
'views/templates/choose-reply.html',
templates=templates,
show_search_box=(len(templates) > 7),
template_type='sms',
templates_and_folders=TemplateList(
current_service,
template_folder_id=from_folder,
user_id=current_user.id,
template_type='sms'
),
template_folder_path=current_service.get_template_folder_path(from_folder),
search_form=SearchByNameForm(),
notification_id=notification_id,
template_type='sms'
)