Skip to content

Commit e8c0f98

Browse files
authored
Merge pull request #2576 from GSA/2570-bug-messages-are-not-being-sent-with-personalizationvariables
reverting PR #2484 because it breaks personalization
2 parents 3d07e6f + 8aa7a63 commit e8c0f98

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

app/main/views/send.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -566,18 +566,18 @@ def _check_messages(service_id, template_id, upload_id, preview_row, **kwargs):
566566
"url": url_for(
567567
"main.send_one_off", service_id=service_id, template_id=template.id
568568
),
569-
"text": "Back to message personalization"
569+
"text": "Back to message personalization",
570570
},
571-
"html": "Back to message personalization"
571+
"html": "Back to message personalization",
572572
}
573573
back_link_from_preview = {
574574
"href": {
575575
"url": url_for(
576576
"main.send_one_off", service_id=service_id, template_id=template.id
577577
),
578-
"text": "Back to message personalization"
578+
"text": "Back to message personalization",
579579
},
580-
"html": "Back to message personalization"
580+
"html": "Back to message personalization",
581581
}
582582
choose_time_form = None
583583
else:
@@ -586,9 +586,9 @@ def _check_messages(service_id, template_id, upload_id, preview_row, **kwargs):
586586
"url": url_for(
587587
"main.send_messages", service_id=service_id, template_id=template.id
588588
),
589-
"text": "Back to upload a file"
589+
"text": "Back to upload a file",
590590
},
591-
"html": "Back to upload a file"
591+
"html": "Back to upload a file",
592592
}
593593
back_link_from_preview = {
594594
"href": {
@@ -598,9 +598,9 @@ def _check_messages(service_id, template_id, upload_id, preview_row, **kwargs):
598598
template_id=template.id,
599599
upload_id=upload_id,
600600
),
601-
"text": "Back to check messages"
601+
"text": "Back to check messages",
602602
},
603-
"html": "Back to check messages"
603+
"html": "Back to check messages",
604604
}
605605
choose_time_form = ChooseTimeForm()
606606

@@ -786,9 +786,9 @@ def get_back_link(
786786
service_id=service_id,
787787
template_id=template.id,
788788
),
789-
"text": "Back to select delivery time"
789+
"text": "Back to select delivery time",
790790
},
791-
"html": "Back to select delivery time"
791+
"html": "Back to select delivery time",
792792
}
793793

794794
if step_index == 0:
@@ -799,9 +799,9 @@ def get_back_link(
799799
".choose_template",
800800
service_id=service_id,
801801
),
802-
"text": "Back to all templates"
802+
"text": "Back to all templates",
803803
},
804-
"html": "Back to all templates"
804+
"html": "Back to all templates",
805805
}
806806
else:
807807
return {
@@ -811,14 +811,16 @@ def get_back_link(
811811
service_id=service_id,
812812
template_id=template.id,
813813
),
814-
"text": "Back to confirm your template"
814+
"text": "Back to confirm your template",
815815
},
816-
"html": "Back to confirm your template"
816+
"html": "Back to confirm your template",
817817
}
818818

819819
# fallback for other steps
820820
back_to_text = (
821-
"Back to select recipients" if step_index == 1 else "Back to message personalization"
821+
"Back to select recipients"
822+
if step_index == 1
823+
else "Back to message personalization"
822824
)
823825

824826
return {
@@ -829,9 +831,9 @@ def get_back_link(
829831
template_id=template.id,
830832
step_index=step_index - 1,
831833
),
832-
"text": back_to_text
834+
"text": back_to_text,
833835
},
834-
"html": back_to_text
836+
"html": back_to_text,
835837
}
836838

837839

app/main/views/tour.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,11 @@ def _get_tour_step_back_link(service_id, template_id, step_index):
142142
return {
143143
"href": {
144144
"url": url_for(
145-
'main.begin_tour',
146-
service_id=service_id,
147-
template_id=template_id
145+
"main.begin_tour", service_id=service_id, template_id=template_id
148146
),
149-
"text": "Back to tour start"
147+
"text": "Back to tour start",
150148
},
151-
"html": "Back to tour start"
149+
"html": "Back to tour start",
152150
}
153151
else:
154152
return {
@@ -207,9 +205,9 @@ def check_tour_notification(service_id, template_id):
207205
template_id=template_id,
208206
step_index=len(placeholders),
209207
),
210-
"text": "Back to previous step"
208+
"text": "Back to previous step",
211209
},
212-
"html": "Back to previous step"
210+
"html": "Back to previous step",
213211
}
214212

215213
template.values = get_recipient_and_placeholders_from_session(

app/s3_client/s3_csv_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_csv_upload(service_id, upload_id):
3131
def remove_blank_lines(filedata):
3232
# sometimes people upload files with hundreds of blank lines at the end
3333
data = filedata["data"]
34-
cleaned_data = "\n".join(line for line in data.splitlines() if line.strip())
34+
cleaned_data = "\r\n".join(line for line in data.splitlines() if line.strip())
3535
filedata["data"] = cleaned_data
3636
return filedata
3737

tests/app/main/views/test_send.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ def test_send_one_off_offers_link_to_upload(
14511451

14521452
assert back_link.text.strip() in {
14531453
"Back to all templates",
1454-
"Back to confirm your template"
1454+
"Back to confirm your template",
14551455
}
14561456

14571457
assert link.text.strip() == "Upload a list of phone numbers"
@@ -2288,7 +2288,9 @@ def test_check_messages_back_link(
22882288
actual_href = page.find_all("a", {"class": "usa-back-link"})[0]["href"]
22892289
expected_href = expected_url(service_id=SERVICE_ONE_ID, template_id=fake_uuid)
22902290

2291-
assert actual_href != "#", "Back link href fell back to '#' — missing correct back_link in view"
2291+
assert (
2292+
actual_href != "#"
2293+
), "Back link href fell back to '#' — missing correct back_link in view"
22922294
assert actual_href == expected_href
22932295

22942296

tests/app/s3_client/test_s3_csv_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_sets_metadata(client_request, mocker):
2525

2626
def test_removes_blank_lines():
2727
filedata = {
28-
"data": "phone number\r\n15555555555\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
28+
"data": "variable,phone number\r\ntest,+15555555555\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"
2929
}
3030
file_data = remove_blank_lines(filedata)
31-
assert file_data == {"data": "phone number\n15555555555"}
31+
assert file_data == {"data": "variable,phone number\r\ntest,+15555555555"}

0 commit comments

Comments
 (0)