diff --git a/microsetta_interface/implementation.py b/microsetta_interface/implementation.py
index af100f03..47dab5de 100644
--- a/microsetta_interface/implementation.py
+++ b/microsetta_interface/implementation.py
@@ -1327,13 +1327,17 @@ def get_create_nonhuman_source(*, account_id=None):
# Note: ideally this would be represented as a DELETE, not as a POST
# However, it is used as a form submission action, and HTML forms do not
# support delete as an action
-def post_request_account_removal(*, account_id):
+def post_request_account_removal(*, account_id, body):
# PUT is used to add the account_id to the queue
# DELETE is used to remove the account_id from the queue, if it's
# still there.
- has_error, put_output, _ = ApiRequest.put(
- '/accounts/%s/removal_queue' %
- (account_id))
+
+ user_delete_reason = body.get('user_delete_reason')
+
+ url = f'/accounts/{account_id}/removal_queue' \
+ f'?user_delete_reason={user_delete_reason}'
+
+ has_error, put_output, _ = ApiRequest.put(url)
if has_error:
return put_output
diff --git a/microsetta_interface/routes.yaml b/microsetta_interface/routes.yaml
index 04cf0950..ffa61523 100644
--- a/microsetta_interface/routes.yaml
+++ b/microsetta_interface/routes.yaml
@@ -595,6 +595,16 @@ paths:
- Account
parameters:
- $ref: '#/components/parameters/account_id'
+ requestBody:
+ required: true
+ content:
+ application/x-www-form-urlencoded:
+ schema:
+ type: object
+ properties:
+ user_delete_reason:
+ type: string
+ nullable: true
responses:
'200':
description: Display of revised info or error info
diff --git a/microsetta_interface/templates/account_details.jinja2 b/microsetta_interface/templates/account_details.jinja2
index 1a36f6a4..8f28e57f 100644
--- a/microsetta_interface/templates/account_details.jinja2
+++ b/microsetta_interface/templates/account_details.jinja2
@@ -132,7 +132,12 @@
function verifyDeleteUserRequest(){
let confirmMsg = "{{ _('You are requesting to delete your account.') }} " +
"{{ _('This operation cannot be undone. Are you sure you want to delete this account?') }} ";
- return window.confirm(confirmMsg);
+
+ let reason = prompt("{{ _('Please provide a reason for deletion (Optional):') }}");
+ document.getElementById("user_delete_reason").value = reason;
+
+ return window.confirm(confirmMsg);
+
}
{% endblock %}
@@ -472,6 +477,7 @@
method="post" action="/accounts/{{ account.account_id }}/request/remove"
onsubmit="return verifyDeleteUserRequest();">
{{ _('If you wish to delete this account, please click the following button to submit your request to an administrator.') }}
+
{{ _('IMPORTANT: Once you click this button, the request cannot be undone. Your account cannot be restored after it has been deleted.') }}
diff --git a/microsetta_interface/templates/admin_requests_account_removal_list.jinja2 b/microsetta_interface/templates/admin_requests_account_removal_list.jinja2
index a92a3ea0..b3a9f030 100644
--- a/microsetta_interface/templates/admin_requests_account_removal_list.jinja2
+++ b/microsetta_interface/templates/admin_requests_account_removal_list.jinja2
@@ -36,6 +36,9 @@