|
31 | 31 | )
|
32 | 32 | from app.main import main, no_cookie
|
33 | 33 | from app.main.forms import (
|
| 34 | + AddRecipientForm, |
34 | 35 | ChooseTimeForm,
|
35 | 36 | CsvUploadForm,
|
36 | 37 | LetterAddressForm,
|
@@ -101,6 +102,9 @@ def send_messages(service_id, template_id):
|
101 | 102 | ),
|
102 | 103 | )
|
103 | 104 |
|
| 105 | + if session["source_call"] == "add_recipients": |
| 106 | + backlink = url_for(".add_recipients", service_id=service_id, template_id=template_id, back="email_reply_to") |
| 107 | + |
104 | 108 | if template.template_type == "email":
|
105 | 109 | template.reply_to = get_email_reply_to_address_from_session()
|
106 | 110 | elif template.template_type == "sms":
|
@@ -162,6 +166,7 @@ def send_messages(service_id, template_id):
|
162 | 166 | form=form,
|
163 | 167 | allowed_file_extensions=Spreadsheet.ALLOWED_FILE_EXTENSIONS,
|
164 | 168 | error_summary_enabled=True,
|
| 169 | + alternative_backlink=backlink, |
165 | 170 | )
|
166 | 171 |
|
167 | 172 |
|
@@ -408,6 +413,44 @@ def send_one_off_letter_address(service_id, template_id):
|
408 | 413 | )
|
409 | 414 |
|
410 | 415 |
|
| 416 | +@main.route("/services/<uuid:service_id>/send/<uuid:template_id>/add-recipients", methods=["GET", "POST"]) |
| 417 | +@user_has_permissions("send_messages") |
| 418 | +def add_recipients(service_id, template_id): |
| 419 | + session["source_call"] = "" |
| 420 | + |
| 421 | + form = AddRecipientForm() |
| 422 | + back = request.args.get("back") |
| 423 | + |
| 424 | + backlink = None |
| 425 | + |
| 426 | + if back == "email_reply_to" and template_id: |
| 427 | + backlink = url_for( |
| 428 | + "main.service_email_reply_to", service_id=service_id, template_id=template_id, back="from_name" |
| 429 | + ) |
| 430 | + |
| 431 | + if form.validate_on_submit(): |
| 432 | + choice = form.add_recipient_method.data |
| 433 | + session["source_call"] = "add_recipients" |
| 434 | + session["add_recipients_choice"] = choice |
| 435 | + |
| 436 | + if choice == "upload_csv": |
| 437 | + return redirect(url_for("main.send_messages", service_id=service_id, template_id=template_id)) |
| 438 | + elif choice == "enter_single": |
| 439 | + return redirect( |
| 440 | + url_for("main.send_one_off_step", service_id=service_id, template_id=template_id, step_index=0) |
| 441 | + ) |
| 442 | + elif choice == "use_my_email": |
| 443 | + return redirect(url_for("main.send_one_off_to_myself", service_id=service_id, template_id=template_id)) |
| 444 | + |
| 445 | + return render_template( |
| 446 | + "views/add-recipients.html", |
| 447 | + form=form, |
| 448 | + template_id=template_id, |
| 449 | + service_id=service_id, |
| 450 | + alternative_backlink=backlink, |
| 451 | + ) |
| 452 | + |
| 453 | + |
411 | 454 | @main.route(
|
412 | 455 | "/services/<uuid:service_id>/send/<uuid:template_id>/one-off/step-<int:step_index>",
|
413 | 456 | methods=["GET", "POST"],
|
@@ -536,6 +579,7 @@ def send_one_off_step(service_id, template_id, step_index): # noqa: C901
|
536 | 579 | back_link=back_link,
|
537 | 580 | link_to_upload=(request.endpoint == "main.send_one_off_step" and step_index == 0),
|
538 | 581 | error_summary_enabled=True,
|
| 582 | + hide_upload_links=session.get("source_call") == "add_recipients", |
539 | 583 | )
|
540 | 584 |
|
541 | 585 |
|
@@ -873,6 +917,9 @@ def _get_set_sender_back_link(service_id, template):
|
873 | 917 |
|
874 | 918 | def get_back_link(service_id, template, step_index, placeholders=None):
|
875 | 919 | if step_index == 0:
|
| 920 | + if session.get("source_call") == "add_recipients": |
| 921 | + return url_for(".add_recipients", service_id=service_id, template_id=template.id, back="email_reply_to") |
| 922 | + |
876 | 923 | if _should_show_set_sender_page(service_id, template):
|
877 | 924 | return url_for("main.set_sender", service_id=service_id, template_id=template.id, from_back_link="yes")
|
878 | 925 | else:
|
@@ -978,7 +1025,10 @@ def _check_notification(service_id, template_id, exception=None):
|
978 | 1025 |
|
979 | 1026 | placeholders = fields_to_fill_in(template)
|
980 | 1027 |
|
981 |
| - back_link = get_back_link(service_id, template, len(placeholders), placeholders) |
| 1028 | + if request.args.get("back") == "add_recipients": |
| 1029 | + back_link = url_for(".add_recipients", service_id=service_id, template_id=template.id, back="email_reply_to") |
| 1030 | + else: |
| 1031 | + back_link = get_back_link(service_id, template, len(placeholders), placeholders) |
982 | 1032 |
|
983 | 1033 | if (not session.get("recipient") and template.template_type != "letter") or not all_placeholders_in_session(
|
984 | 1034 | template.placeholders
|
|
0 commit comments