Skip to content

Commit

Permalink
added user delete reason
Browse files Browse the repository at this point in the history
  • Loading branch information
ayobi committed Feb 13, 2024
1 parent 3b12786 commit 836bf18
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
12 changes: 8 additions & 4 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions microsetta_interface/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion microsetta_interface/templates/account_details.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
</script>
{% endblock %}
Expand Down Expand Up @@ -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.') }}
<input type="hidden" id="user_delete_reason" name="user_delete_reason" value="{{ account.user_delete_reason}}">
<button type="submit" class="btn btn-outline-danger">{{ _('Request Account Deletion') }}</button>
<br>
{{ _('IMPORTANT: Once you click this button, the request cannot be undone. Your account cannot be restored after it has been deleted.') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<div class="col-sm" style="text-align: center">
<i>{{ _('Requested On') }}</i>
</div>
<div class="col-sm" style="text-align: center">
<i>{{ _('Reason for Deletion') }}</i>
</div>
<div class="col-sm" style="text-align: center">
&nbsp;
</div>
Expand Down Expand Up @@ -64,6 +67,9 @@
<div class="col-sm" style="text-align: center">
{{ row.requested_on |e }}
</div>
<div class="col-sm" style="text-align: center">
{{ row.user_delete_reason |e }}
</div>
<div class="col-sm" style="text-align: right">
<form action="/admin/account_delete" method="post" onsubmit="return verifyDeleteRequest();">
<input type="hidden" id="btnDelete" name="account_id" value="{{ row.account_id }}"/>
Expand Down

0 comments on commit 836bf18

Please sign in to comment.