Skip to content

Commit d4504bb

Browse files
committed
Delete unused HTML and plaintext methods
1 parent 192161f commit d4504bb

4 files changed

Lines changed: 7 additions & 391 deletions

File tree

app/lib/ses_email_formatter.rb

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ def initialize(submission_reference:, steps:, confirmation_email:)
1212
@confirmation_email = confirmation_email
1313
end
1414

15-
def build_question_answers_section_html(heading_level: 3)
16-
@steps.map { |step|
17-
[prep_question_title_html(step, heading_level),
18-
prep_answer_text_html(step)].join
19-
}.join(H_RULE)
20-
end
21-
22-
def build_question_answers_section_plain_text
23-
@steps.map { |step|
24-
[prep_question_title_plain_text(step),
25-
prep_answer_text_plain_text(step)].join("\n\n")
26-
}.join(H_RULE_PLAIN_TEXT)
27-
end
28-
2915
def build_question_answers_section_markdown(heading_level: 3)
3016
@steps.map { |step|
3117
[prep_question_title_markdown(step, heading_level),
@@ -35,72 +21,35 @@ def build_question_answers_section_markdown(heading_level: 3)
3521

3622
private
3723

38-
def prep_question_title_html(step, heading_level)
39-
case heading_level
40-
when 3
41-
"<h3 style=\"font-size: 21px; line-height: 25px; font-weight: bold; color: #0B0C0C;\">#{prep_question_title_plain_text(step)}</h3>"
42-
when 4
43-
"<h4 style=\"font-size: 19px; line-height: 25px; font-weight: bold; color: #0B0C0C;\">#{prep_question_title_plain_text(step)}</h4>"
44-
else
45-
raise FormattingError, "unsupported heading level: #{heading_level}"
46-
end
47-
end
48-
4924
def prep_question_title_markdown(step, heading_level)
5025
case heading_level
5126
when 3
52-
"### #{prep_question_title_plain_text(step)}"
27+
"### #{step.question.question_text}"
5328
when 4
54-
"#### #{prep_question_title_plain_text(step)}"
29+
"#### #{step.question.question_text}"
5530
else
5631
raise FormattingError, "unsupported heading level: #{heading_level}"
5732
end
5833
end
5934

60-
def prep_answer_text_html(step)
61-
if step.is_selection_with_none_of_the_above_answer?
62-
prep_html_none_of_the_above_answer_text(step)
63-
else
64-
"<p>#{convert_newlines_to_html(prep_answer_text(step))}</p>"
65-
end
66-
rescue StandardError
67-
raise FormattingError, "could not format answer for question step #{step.id}"
68-
end
69-
7035
def prep_answer_text_markdown(step)
7136
if step.is_selection_with_none_of_the_above_answer?
72-
prep_markdown_none_of_the_above_answer_text(step)
37+
prep_none_of_the_above_answer_text_markdown(step)
7338
else
7439
prep_answer_text(step)
7540
end
7641
rescue StandardError
7742
raise FormattingError, "could not format answer for question step #{step.id}"
7843
end
7944

80-
def prep_html_none_of_the_above_answer_text(step)
81-
[
82-
"<p>#{convert_newlines_to_html(prep_answer_text(step))}</p>",
83-
"<h4>#{convert_newlines_to_html(prep_none_of_the_above_question_text(step))}</h4>",
84-
"<p>#{convert_newlines_to_html(prep_none_of_the_above_answer_text(step))}</p>",
85-
]
86-
end
87-
88-
def prep_markdown_none_of_the_above_answer_text(step)
45+
def prep_none_of_the_above_answer_text_markdown(step)
8946
[
9047
prep_answer_text(step),
91-
"#### #{prep_none_of_the_above_question_text(step)}",
92-
prep_none_of_the_above_answer_text(step),
48+
"#### #{step.question.none_of_the_above_question_text}",
49+
prep_none_of_the_above_answer_markdown(step),
9350
].join("\n\n")
9451
end
9552

96-
def prep_question_title_plain_text(step)
97-
step.question.question_text
98-
end
99-
100-
def prep_none_of_the_above_question_text(step)
101-
step.question.none_of_the_above_question_text
102-
end
103-
10453
def prep_answer_text(step)
10554
answer = step.show_answer_in_email(submission_reference: @submission_reference, confirmation_email: @confirmation_email)
10655

@@ -111,7 +60,7 @@ def prep_answer_text(step)
11160
raise FormattingError, "could not format answer for question step #{step.id}"
11261
end
11362

114-
def prep_none_of_the_above_answer_text(step)
63+
def prep_none_of_the_above_answer_markdown(step)
11564
answer = step.question.none_of_the_above_answer
11665

11766
return skipped_question_text if answer.blank?
@@ -121,22 +70,6 @@ def prep_none_of_the_above_answer_text(step)
12170
raise FormattingError, "could not format none of the above answer for question step #{step.id}"
12271
end
12372

124-
def prep_answer_text_plain_text(step)
125-
if step.is_selection_with_none_of_the_above_answer?
126-
prep_plain_text_none_of_the_above_answer_text(step)
127-
else
128-
prep_answer_text(step)
129-
end
130-
end
131-
132-
def prep_plain_text_none_of_the_above_answer_text(step)
133-
[
134-
prep_answer_text(step),
135-
prep_none_of_the_above_question_text(step),
136-
prep_none_of_the_above_answer_text(step),
137-
].join("\n\n")
138-
end
139-
14073
def sanitize(text)
14174
text
14275
.then { normalize_whitespace _1 }

app/models/submission.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ def mode_object
5959
Mode.new(mode)
6060
end
6161

62-
def answer_content_for_email_html(heading_level:, locale: :en, confirmation_email: false)
63-
ses_email_formatter(locale, confirmation_email).build_question_answers_section_html(heading_level:)
64-
end
65-
66-
def answer_content_for_email_plain_text(locale: :en, confirmation_email: false)
67-
ses_email_formatter(locale, confirmation_email).build_question_answers_section_plain_text
68-
end
69-
7062
def answer_content_for_email_markdown(heading_level:, locale: :en, confirmation_email: false)
7163
ses_email_formatter(locale, confirmation_email).build_question_answers_section_markdown(heading_level:)
7264
end

0 commit comments

Comments
 (0)