Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 69 additions & 3 deletions app/main/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,77 @@ class SupportType(StripWhitespaceForm):


class SupportProblemTypeForm(StripWhitespaceForm):
problem_type = GovukRadiosField(
def __init__(self, *args, user_logged_in, **kwargs):
super().__init__(*args, **kwargs)

if user_logged_in:
self.problem_type.choices = [
("sending-messages", "I’m having problems sending messages"),
("something-else", "Something else"),
]
else:
self.problem_type.choices = [
("signing-in", "I cannot sign in to my account"),
("sending-messages", "I’m having problems sending messages"),
("something-else", "Something else"),
]

problem_type = GovukRadiosField("")


class SupportSignInIssuesForm(StripWhitespaceForm):
sign_in_issue = GovukRadiosField(
"Tell us why you cannot sign in",
choices=[
("sending-messages", "I’m having problems sending messages"),
("no-code", "I did not receive a text message with a security code"),
("mobile-number-changed", "My mobile number has changed"),
("no-email-link", "I did not receive an email with a link to sign in"),
("email-address-changed", "My email address has changed"),
("something-else", "Something else"),
]
],
)


class SupportNoSecurityCodeForm(StripWhitespaceForm):
name = GovukTextInputField("Name", validators=[NotifyDataRequired(thing="your name")])
email_address = make_email_address_field(
label="Email address", gov_user=False, required=True, thing="your email address"
)
mobile_number = PhoneNumber(
"Mobile number",
validators=[NotifyDataRequired(thing="your mobile number"), ValidPhoneNumber(allow_international_sms=True)],
)


class SupportMobileNumberChangedForm(StripWhitespaceForm):
name = GovukTextInputField("Name", validators=[NotifyDataRequired(thing="your name")])
email_address = make_email_address_field(
label="Email address", gov_user=False, required=True, thing="your email address"
)
old_mobile_number = PhoneNumber(
"Old mobile number",
validators=[NotifyDataRequired(thing="your old mobile number"), ValidPhoneNumber(allow_international_sms=True)],
)
new_mobile_number = PhoneNumber(
"New mobile number",
validators=[NotifyDataRequired(thing="your new mobile number"), ValidPhoneNumber(allow_international_sms=True)],
)


class SupportNoEmailLinkForm(StripWhitespaceForm):
name = GovukTextInputField("Name", validators=[NotifyDataRequired(thing="your name")])
email_address = make_email_address_field(
label="Email address", gov_user=False, required=True, thing="your email address"
)


class SupportEmailAddressChangedForm(StripWhitespaceForm):
name = GovukTextInputField("Name", validators=[NotifyDataRequired(thing="your name")])
old_email_address = make_email_address_field(
label="Old email address", gov_user=False, required=True, thing="your old email address"
)
new_email_address = make_email_address_field(
label="New email address", gov_user=False, required=True, thing="your new email address"
)


Expand Down
205 changes: 203 additions & 2 deletions app/main/views/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
from app.main import main
from app.main.forms import (
FeedbackOrProblem,
SupportEmailAddressChangedForm,
SupportMobileNumberChangedForm,
SupportNoEmailLinkForm,
SupportNoSecurityCodeForm,
SupportProblemTypeForm,
SupportRedirect,
SupportSignInIssuesForm,
SupportType,
SupportWhatHappenedForm,
)
Expand Down Expand Up @@ -81,12 +86,14 @@ def support_what_do_you_want_to_do():
@main.route("/support/problem", methods=["GET", "POST"])
@hide_from_search_engines
def support_problem():
form = SupportProblemTypeForm()
form = SupportProblemTypeForm(user_logged_in=current_user.is_authenticated)

back_link = url_for(".support") if current_user.is_authenticated else url_for(".support_what_do_you_want_to_do")

if form.validate_on_submit():
if form.problem_type.data == "sending-messages":
if form.problem_type.data == "signing-in":
return redirect(url_for("main.support_cannot_sign_in"))
elif form.problem_type.data == "sending-messages":
return redirect(url_for("main.support_what_happened"))
elif form.problem_type.data == "something-else":
return redirect(
Expand All @@ -95,6 +102,195 @@ def support_problem():
return render_template("views/support/problem.html", back_link=back_link, form=form, error_summary_enabled=True)


@main.route("/support/cannot-sign-in", methods=["GET", "POST"])
@hide_from_search_engines
def support_cannot_sign_in():
form = SupportSignInIssuesForm()

if form.validate_on_submit():
if form.sign_in_issue.data == "no-code":
return redirect(url_for("main.support_no_security_code"))
elif form.sign_in_issue.data == "mobile-number-changed":
return redirect(url_for("main.support_mobile_number_changed"))
elif form.sign_in_issue.data == "no-email-link":
return redirect(url_for("main.support_no_email_link"))
elif form.sign_in_issue.data == "email-address-changed":
return redirect(url_for("main.support_email_address_changed"))
elif form.sign_in_issue.data == "something-else":
return redirect(
url_for("main.feedback", ticket_type=PROBLEM_TICKET_TYPE, severe="no", category="cannot-sign-in")
)

return render_template("views/support/cannot-sign-in.html", form=form, error_summary_enabled=True)


@main.route("/support/security-code")
@hide_from_search_engines
def support_no_security_code():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

return render_template("views/support/no-security-code.html")


@main.route("/support/mobile-number-changed")
@hide_from_search_engines
def support_mobile_number_changed():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

return render_template("views/support/mobile-number-changed.html")


@main.route("/support/email-link")
@hide_from_search_engines
def support_no_email_link():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

return render_template("views/support/no-email-link.html")


@main.route("/support/email-address-changed")
@hide_from_search_engines
def support_email_address_changed():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

return render_template("views/support/email-address-changed.html")


def create_sign_in_issues_zendesk_ticket(subject, message, name, email, notifiy_ticket_type=None):
prefix = (
""
if not current_app.config["FEEDBACK_ZENDESK_SUBJECT_PREFIX_ENABLED"]
else f"[env: {current_app.config['NOTIFY_ENVIRONMENT']}] "
)

ticket = NotifySupportTicket(
subject=f"{prefix}{subject}",
message=message,
ticket_type=get_zendesk_ticket_type(PROBLEM_TICKET_TYPE),
notify_ticket_type=notifiy_ticket_type,
user_name=name,
user_email=email,
requester_sees_message_content=False,
)
zendesk_client.send_ticket_to_zendesk(ticket)


@main.route("/support/security-code/account-details", methods=["GET", "POST"])
@hide_from_search_engines
def support_no_security_code_account_details():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

form = SupportNoSecurityCodeForm()

if form.validate_on_submit():
feedback_msg = render_template(
"support-tickets/sign-in-issue-no-security-code.txt",
user_mobile=form.mobile_number.data,
)
create_sign_in_issues_zendesk_ticket(
subject="Security code not received",
message=feedback_msg,
name=form.name.data,
email=form.email_address.data,
)

return redirect(url_for("main.thanks"))

return render_template("views/support/no-security-code-account-details.html", form=form, error_summary_enabled=True)


@main.route("/support/mobile-number-changed/account-details", methods=["GET", "POST"])
@hide_from_search_engines
def support_mobile_number_changed_account_details():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

form = SupportMobileNumberChangedForm()

if form.validate_on_submit():
feedback_msg = render_template(
"support-tickets/sign-in-issue-mobile-number-changed.txt",
old_mobile_number=form.old_mobile_number.data,
new_mobile_number=form.new_mobile_number.data,
)
create_sign_in_issues_zendesk_ticket(
subject="Change mobile number",
message=feedback_msg,
name=form.name.data,
email=form.email_address.data,
notifiy_ticket_type=NotifyTicketType.NON_TECHNICAL,
)

return redirect(url_for("main.thanks"))

return render_template(
"views/support/mobile-number-changed-account-details.html",
form=form,
error_summary_enabled=True,
)


@main.route("/support/email-link/account-details", methods=["GET", "POST"])
@hide_from_search_engines
def support_no_email_link_account_details():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

form = SupportNoEmailLinkForm()

if form.validate_on_submit():
feedback_msg = render_template(
"support-tickets/sign-in-issue-no-email-link.txt",
user_email_address=form.email_address.data,
)
create_sign_in_issues_zendesk_ticket(
subject="Email link not received",
message=feedback_msg,
name=form.name.data,
email=form.email_address.data,
)

return redirect(url_for("main.thanks"))

return render_template("views/support/no-email-link-account-details.html", form=form, error_summary_enabled=True)


@main.route("/support/email-address-changed/account-details", methods=["GET", "POST"])
@hide_from_search_engines
def support_email_address_changed_account_details():
if current_user.is_authenticated:
return redirect(url_for("main.support_problem"))

form = SupportEmailAddressChangedForm()

if form.validate_on_submit():
feedback_msg = render_template(
"support-tickets/sign-in-issue-email-address-changed.txt",
old_email_address=form.old_email_address.data,
new_email_address=form.new_email_address.data,
)
create_sign_in_issues_zendesk_ticket(
subject="Change email address",
message=feedback_msg,
name=form.name.data,
email=form.new_email_address.data,
notifiy_ticket_type=NotifyTicketType.NON_TECHNICAL,
)

return redirect(url_for("main.thanks"))

return render_template(
"views/support/email-address-changed-account-details.html",
form=form,
error_summary_enabled=True,
)


@main.route("/support/what-happened", methods=["GET", "POST"])
@hide_from_search_engines
def support_what_happened():
Expand Down Expand Up @@ -165,6 +361,11 @@ def support_public():
"back_link": "main.support_what_happened",
"notify_ticket_type": NotifyTicketType.TECHNICAL,
},
"cannot-sign-in": {
"zendesk_subject": "Cannot sign in",
"back_link": "main.support_problem",
"notify_ticket_type": None,
},
},
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
User’s email address has changed

Old email address: {{ old_email_address }}

New email address: {{ new_email_address }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
User’s mobile number has changed

Old mobile number: {{ old_mobile_number }}

New mobile number: {{ new_mobile_number }}
3 changes: 3 additions & 0 deletions app/templates/support-tickets/sign-in-issue-no-email-link.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User did not receive an email link

Email address: {{ user_email_address }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
User did not receive a security code

Mobile number: {{ user_mobile }}
29 changes: 29 additions & 0 deletions app/templates/views/support/cannot-sign-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "withoutnav_template.html" %}
{% from "components/page-footer.html" import page_footer %}
{% from "components/form.html" import form_wrapper %}
{% from "govuk_frontend_jinja/components/back-link/macro.html" import govukBackLink %}


{% block per_page_title %}
Tell us why you cannot sign in
{% endblock %}

{% block backLink %}
{{ govukBackLink({ "href": url_for("main.support_problem") }) }}
{% endblock %}

{% block maincolumn_content %}
{% call form_wrapper() %}
{{ form.sign_in_issue(param_extensions={
'fieldset': {
'legend': {
'isPageHeading': True,
'classes': 'govuk-fieldset__legend--l'
}
}
}) }}

{{ page_footer('Continue') }}
{% endcall %}

{% endblock %}
Loading