Skip to content

Commit

Permalink
RAS-1201 Delete an account (#1030)
Browse files Browse the repository at this point in the history
* RAS-1201 Delete an account
  • Loading branch information
LJBabbage authored Jan 23, 2025
1 parent 275899a commit d3c547a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
35 changes: 11 additions & 24 deletions frontstage/templates/account/account-delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@
{% from "components/panel/_macro.njk" import onsPanel %}

{% set page_title = "Account delete" %}
{% set breadcrumbsData = [
{
"text": "Surveys",
"url": "/surveys/todo",
"id": "b-item"
}
] %}

{% block breadcrumbs %}
{{
onsBreadcrumbs({
"ariaLabel": "Breadcrumbs",
"id": "breadcrumbs",
"itemsList": breadcrumbsData
})
}}
{% endblock breadcrumbs %}

{% block main %}
{%- with messages = get_flashed_messages(category_filter=["info"]) -%}
Expand All @@ -46,28 +29,32 @@ <h1 class="ons-u-fs-xl">Delete account</h1>
"variant": 'warn'
})
%}
<p>All of the information about your account will be deleted.</p>
<p>Once your data has been removed, it cannot be recovered.</p>
<p>Once your account has been deleted, you will not be able to recover any of your data.</p>
<p>You will not be able to set up a new account until you are selected for a new survey.</p>
{% endcall %}
<h2 class="ons-u-fs-l">Are you sure you want to delete your account?</h2>
{% endif %}
<form action="" method="post">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div class="ons-grid ons-grid-flex ons-grid--gutterless ons-grid-flex--vertical-center ons-grid--no-wrap@s ons-u-mt-m ons-u-mb-m">
{% if is_validated %}
<div class="ons-grid__col">
{{
onsButton({
"text": "Delete account",
"id": "btn-option-delete-account",
"submitType": "timer"
})
}}
</div>
{% endif %}
<div class="ons-grid__col ons-u-ml-m">
<a href="{{ url_for('surveys_bp.get_survey_list', tag='todo') }}" id="btn-option-cancel">Cancel</a>
</div>
{{
onsButton({
"id": "btn-cancel",
"url": url_for('surveys_bp.get_survey_list', tag='todo'),
"text": 'Cancel',
"variants": 'secondary',
"noIcon": true
})
}}
</div>
</form>
{% endblock main %}
1 change: 1 addition & 0 deletions frontstage/views/account/account_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def delete_user_account(session):
if request.method == "POST":
respondent = party_controller.get_respondent_party_by_id(party_id)
delete_account(respondent["emailAddress"])
flash("Your account is deleted.", "success")
return redirect(url_for("sign_in_bp.logout"))

return render_template("account/account-delete.html", session=session, is_validated=True)
6 changes: 4 additions & 2 deletions tests/integration/views/account/test_account_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ def test_account_delete(self, mock_request, get_respondent_enrolments, get_respo

self.assertEqual(response.status_code, 200)
self.assertTrue("Delete account".encode() in response.data)
self.assertTrue("All of the information about your account will be deleted.".encode() in response.data)
self.assertTrue("Once your data has been removed, it cannot be recovered.".encode() in response.data)
self.assertTrue(
"Once your account has been deleted, you will not be able to recover any of your data".encode()
in response.data
)
self.assertTrue(
"You will not be able to set up a new account until you are selected for a new survey.".encode()
in response.data
Expand Down

0 comments on commit d3c547a

Please sign in to comment.