Repository: mdn/kuma

Issue:
User acct deletion: modal overlay to confirm/cancel user deletion. 
**Parent ticket:**
https://github.com/mdn/sprints/issues/1922

**Description:**
Overlay appears on MDN profile page when a logged-in MDN user clicks on 'Delete Account' link. 

**Acceptance Criteria:**
- [x] Modal needs to work on all devices. (for mobile - will go to a separate screen)
- [x] Clicking on 'Cancel' closes modal
- [x] Clicking on 'Yes, Delete my Account' executes deletion and closes modal. 

**Design:**
https://mozilla.invisionapp.com/share/Y8SGMKQBCW3#/screens/370705983_Account_-_Profile_-_Delete_Account_-no_Contrib-




Discussion:
@atopal where should the 'Delete Account' link (that launches the modal) appear on the profile page? (I don't see it on the design)
> @atopal where should the 'Delete Account' link (that launches the modal) appear on the profile page? (I don't see it on the design)

That will be at the bottom of the edit profile page. I will spin up a separate issue for the UI portion of this work.
Never mind, this is that issue ;)
Hi @schalkneethling, a couple questions for you:

- re: status. is this currently still waiting to be done?
- is this still blocked by the sign-in landing page issue? 
> Hi @schalkneethling, a couple questions for you:
> 
> * re: status. is this currently still waiting to be done?
> * is this still blocked by the sign-in landing page issue?

This is ready to move to Ready for Dev. One question I have is, while I am in there in the weeds of the edit profile view, why not go ahead and start cleaning up?

There are a *lot* of fields we know we will not be using going forward so, the sooner we start cleaning up the better i.e. follow on work will be much quicker.

I can also then take care of removing jQueryUI, added the React-based header, and start updating the UI to use the new styling for button etc.

Let me know @tobinmori - Thanks!
I'm all for cleanup @schalkneethling! 

Let me defer this to @atopal.  Are you ok with this? (as it might delay this task a bit, but mean faster movement later. . .)
The other thing that we discussed @schalkneethling yesterday is that the existing design for the user deletion needs to be revamped. Let's talk about that when you have a chance.
@atopal to test out existing functionality and verify whether to keep it, or update it.
I looked into this.

1. I don't know what the flow looks like for someone without any contributions. Does it immediately delete the account without any further message after the first "delete account" link click?
2. I don't know what happens when you actually click "delete my account" on the follow up page.

Can someone provide screenshots?

How this is different from the original design:
1. Message about deleting your account.
2. Scary red button for deleting account
3. Keep attribution doesn't show the username that would be attributed
4. Lists the number of contributions
5. Missing the explanation for why we are asking about attribution.

We can talk about adjusting what we have, but I think it's easier to just go ahead and implement the original design.
Quick "answer" is that it looks like the screenshots in https://github.com/mdn/kuma/pull/6149
And from skimming https://github.com/mdn/kuma/blob/master/kuma/users/jinja2/users/user_delete.html it appears that if you have 0 contributions it'll say 
```html
     <p>We're sorry to see you go.</p>

        <p>
          You have made 0 wiki revisions.
        </p>

<button type="submit" class="button positive">Delete my account</button>
```

I'm guessing this is for Schalk. But it'll be obvious once he sets aside the time to work on this further. 

Note to self: https://github.com/mdn/sprints/issues/1635
Links to some of the designs from Nick:

* [Edit profile page with `Delete Account` button](https://mozilla.invisionapp.com/share/Y8SGMKQBCW3#/screens/372750124_Account_-_Profile_-_Filled)
* [No contributions made modal](https://mozilla.invisionapp.com/share/Y8SGMKQBCW3#/screens/370705983_Account_-_Profile_-_Delete_Account_-no_Contrib-)
* [1+ Contributions made step 1](https://mozilla.invisionapp.com/share/Y8SGMKQBCW3#/screens/370705982_Account_-_Profile_-_Delete_Account_-has_Contrib-)
* [1+ Contributions made step 2](https://mozilla.invisionapp.com/share/Y8SGMKQBCW3#/screens/370705981_Account_-_Profile_-_Delete_Account_-_Filled_-has_Contrib-)

Resolving patch:
diff --git a/kuma/settings/common.py b/kuma/settings/common.py
--- a/kuma/settings/common.py
+++ b/kuma/settings/common.py
@@ -792,6 +792,12 @@ def pipeline_one_scss(slug, **kwargs):
         ),
         'output_filename': 'build/styles/users.css',
     },
+    'delete-user-modal': {
+        'source_filenames': (
+            'styles/minimalist/components/delete-user-modal.scss',
+        ),
+        'output_filename': 'build/styles/delete-user-modal.css',
+    },
     'tagit': {
         'source_filenames': (
             'styles/libs/jquery.tagit.css',
@@ -1017,6 +1023,26 @@ def pipeline_one_scss(slug, **kwargs):
             'async': True,
         },
     },
+    'delete-user-page': {
+        'source_filenames': (
+            'js/components/account-management/delete-user-confirmation-button.js',
+        ),
+        'output_filename': 'build/js/delete-user-confirmation-button.js',
+        'extra_context': {
+            'defer': True,
+        },
+    },
+    'delete-user-modal': {
+        'source_filenames': (
+            'js/components/modal.js',
+            'js/components/account-management/delete-user-modal.js',
+            'js/components/account-management/delete-user-confirmation-button.js',
+        ),
+        'output_filename': 'build/js/delete-user-modal.js',
+        'extra_context': {
+            'defer': True,
+        },
+    },
     'auth-modal': {
         'source_filenames': (
             'js/components/modal.js',
diff --git a/kuma/users/forms.py b/kuma/users/forms.py
--- a/kuma/users/forms.py
+++ b/kuma/users/forms.py
@@ -208,14 +208,12 @@ class UserDeleteForm(forms.Form):
     ATTRIBUTIONS_CHOICES = (
         (
             ATTRIBUTIONS_KEEP, _(
-                'Keep my attribution for my page changes; delete my email '
-                'address and freeze my account so I can\'t ever log in again.'
+                'Keep my attribution for my page changes'
             )
         ),
         (
             ATTRIBUTIONS_DONATE, _(
-                'Switch all my attributions for page changes to "Anonymous", '
-                'and delete my account.'
+                'Switch my attribution for my page changes to "Anonymous"'
             )
         ),
     )
diff --git a/kuma/users/views.py b/kuma/users/views.py
--- a/kuma/users/views.py
+++ b/kuma/users/views.py
@@ -403,6 +403,8 @@ def user_edit(request, username):
         ('expertise', 'profile:expertise:')
     )
 
+    revisions = Revision.objects.filter(creator=edit_user)
+
     if request.method != 'POST':
         initial = {
             'beta': edit_user.is_beta_tester,
@@ -450,7 +452,10 @@ def user_edit(request, username):
     context = {
         'edit_user': edit_user,
         'user_form': user_form,
+        'username': user_form['username'].value(),
+        'form': UserDeleteForm(),
         'INTEREST_SUGGESTIONS': INTEREST_SUGGESTIONS,
+        'revisions': revisions,
     }
     return render(request, 'users/user_edit.html', context)
 
@@ -542,6 +547,7 @@ def delete_user():
         form = UserDeleteForm()
 
     context['form'] = form
+    context['username'] = username
     context['revisions'] = revisions
 
     return render(request, 'users/user_delete.html', context)


Test patch: