We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
T - Add opt-in checkbox for marketing email to account creation page. 
**Acceptance Criteria**

- [ ] Add opt-in checkbox for marketing email to account creation page. 
- [ ] Upon acct creation opt-in/out value is stored in our database for the given user

**Design comp**
- see comp [https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/313$](https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3134)
T - Add opt-in checkbox for marketing email to the Edit Profile Page. 
**Acceptance Criteria**

- [ ] Add opt-in checkbox for marketing email to the Edit Profile Page
- [ ] Saves user's selection (opt-in/out) to the database
- [ ] Stub out functionality: add user to correct email group in sendinblue (*feedback needed from Kadir)
- [ ] Update 'Publish' button to read 'Save', see comps
- [ ] Update 'Delete Account' to be a button, see comps
- [ ] This functionality should be behind a waffle flag allowing us to turn on once sendinblue is official

**Comps**
[https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3136](https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3136)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kuma/users/forms.py`
Content:
```
1 from django import forms
2 from django.conf import settings
3 from django.utils.translation import gettext_lazy as _
4 from sundial.forms import TimezoneChoiceField
5 from sundial.zones import COMMON_GROUPED_CHOICES
6 
7 
8 from .constants import USERNAME_CHARACTERS, USERNAME_LEGACY_REGEX, USERNAME_REGEX
9 from .models import User
10 from .tasks import send_recovery_email
11 
12 
13 class UserBanForm(forms.Form):
14     """
15     The form used in the view that enables admins to ban users.
16     """
17 
18     reason = forms.CharField(widget=forms.Textarea)
19 
20 
21 class UserEditForm(forms.ModelForm):
22     """
23     The main form to edit user profile data.
24 
25     It dynamically adds a bunch of fields for maintaining information
26     about a user's websites
27     """
28 
29     timezone = TimezoneChoiceField(
30         label=_("Timezone"),
31         initial=settings.TIME_ZONE,
32         choices=COMMON_GROUPED_CHOICES,
33         required=False,
34     )
35     beta = forms.BooleanField(label=_("Beta tester"), required=False,)
36     username = forms.RegexField(
37         label=_("Username"),
38         regex=USERNAME_REGEX,
39         max_length=30,
40         required=False,
41         error_messages={"invalid": USERNAME_CHARACTERS},
42     )
43     twitter_url = forms.CharField(
44         label=_("Twitter"),
45         required=False,
46         validators=[User.WEBSITE_VALIDATORS["twitter"]],
47         widget=forms.TextInput(
48             attrs={
49                 "placeholder": "https://twitter.com/",
50                 "data-fa-icon": "icon-twitter",
51             }
52         ),
53     )
54     github_url = forms.CharField(
55         label=_("GitHub"),
56         required=False,
57         validators=[User.WEBSITE_VALIDATORS["github"]],
58         widget=forms.TextInput(
59             attrs={"placeholder": "https://github.com/", "data-fa-icon": "icon-github"}
60         ),
61     )
62     is_github_url_public = forms.BooleanField(
63         label=_("Display a link to GitHub on my profile"), required=False
64     )
65     stackoverflow_url = forms.CharField(
66         label=_("Stack Overflow"),
67         required=False,
68         validators=[User.WEBSITE_VALIDATORS["stackoverflow"]],
69         widget=forms.TextInput(
70             attrs={
71                 "placeholder": "https://stackoverflow.com/users/",
72                 "data-fa-icon": "icon-stackexchange",
73             }
74         ),
75     )
76     linkedin_url = forms.CharField(
77         label=_("LinkedIn"),
78         required=False,
79         validators=[User.WEBSITE_VALIDATORS["linkedin"]],
80         widget=forms.TextInput(
81             attrs={
82                 "placeholder": "https://www.linkedin.com/",
83                 "data-fa-icon": "icon-linkedin",
84             }
85         ),
86     )
87     mozillians_url = forms.CharField(
88         label=_("Mozillians"),
89         required=False,
90         validators=[User.WEBSITE_VALIDATORS["mozillians"]],
91         widget=forms.TextInput(
92             attrs={
93                 "placeholder": "https://mozillians.org/u/",
94                 "data-fa-icon": "icon-group",
95             }
96         ),
97     )
98     facebook_url = forms.CharField(
99         label=_("Facebook"),
100         required=False,
101         validators=[User.WEBSITE_VALIDATORS["facebook"]],
102         widget=forms.TextInput(
103             attrs={
104                 "placeholder": "https://www.facebook.com/",
105                 "data-fa-icon": "icon-facebook",
106             }
107         ),
108     )
109     discourse_url = forms.CharField(
110         label=_("Discourse"),
111         required=False,
112         validators=[User.WEBSITE_VALIDATORS["discourse"]],
113         widget=forms.TextInput(
114             attrs={
115                 "placeholder": "https://discourse.mozilla.org/u/",
116                 "data-fa-icon": "icon-discourse",
117             }
118         ),
119     )
120 
121     class Meta:
122         model = User
123         fields = (
124             "fullname",
125             "title",
126             "organization",
127             "location",
128             "locale",
129             "timezone",
130             "irc_nickname",
131             "twitter_url",
132             "github_url",
133             "is_github_url_public",
134             "stackoverflow_url",
135             "linkedin_url",
136             "mozillians_url",
137             "facebook_url",
138             "discourse_url",
139             "username",
140         )
141 
142     def __init__(self, *args, **kwargs):
143         super(UserEditForm, self).__init__(*args, **kwargs)
144         # in case the username is not changed and the user has a legacy
145         # username we want to disarm the username regex
146         if (
147             "username" not in self.changed_data
148             and self.instance
149             and self.instance.has_legacy_username
150         ):
151             self.fields["username"].regex = USERNAME_LEGACY_REGEX
152 
153     def clean_username(self):
154         new_username = self.cleaned_data["username"]
155 
156         if not new_username:
157             raise forms.ValidationError(_("This field cannot be blank."))
158 
159         if (
160             self.instance is not None
161             and User.objects.exclude(pk=self.instance.pk)
162             .filter(username=new_username)
163             .exists()
164         ):
165             raise forms.ValidationError(_("Username already in use."))
166         return new_username
167 
168 
169 class UserRecoveryEmailForm(forms.Form):
170     """
171     Send email(s) with an account recovery link.
172 
173     Modeled after django.contrib.auth.forms.PasswordResetForm
174     """
175 
176     email = forms.EmailField(label=_("Email"), max_length=254)
177 
178     def save(self, request):
179         """
180         Send email(s) with an account recovery link.
181         """
182         email = self.cleaned_data["email"]
183 
184         # Gather matching active users
185         active_users = User.objects.filter(is_active=True)
186         # Users using email as the primary contact email
187         primary_users = active_users.filter(email__iexact=email)
188         # Users with a matching Persona account
189         personas = active_users.filter(
190             socialaccount__uid__iexact=email, socialaccount__provider="persona"
191         )
192         # Users with that confirmed email
193         confirmed = active_users.filter(emailaddress__email__iexact=email)
194 
195         # Send one account recovery email to each matching user
196         user_pks = set()
197         user_pks.update(primary_users.values_list("pk", flat=True))
198         user_pks.update(personas.values_list("pk", flat=True))
199         user_pks.update(confirmed.values_list("pk", flat=True))
200         for user_pk in sorted(user_pks):
201             # TODO figure out why this isn't a .delay() call.
202             # https://bugzilla.mozilla.org/show_bug.cgi?id=1544925
203             send_recovery_email(user_pk, email, request.LANGUAGE_CODE)
204 
205 
206 class UserDeleteForm(forms.Form):
207     def __init__(self, *args, username, **kwargs):
208         super().__init__(*args, **kwargs)
209 
210         choices = {
211             "keep": (
212                 _("Keep my attribution for my page changes (%(username)s)")
213                 % {"username": username}
214             ),
215             "donate": _('Switch my attribution for my page changes to "Anonymous"'),
216         }
217 
218         self.fields["attributions"].choices = choices.items()
219 
220     attributions = forms.ChoiceField(required=True, widget=forms.widgets.RadioSelect())
221
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kuma/users/forms.py b/kuma/users/forms.py
--- a/kuma/users/forms.py
+++ b/kuma/users/forms.py
@@ -117,6 +117,7 @@
             }
         ),
     )
+    is_newsletter_subscribed = forms.BooleanField(required=False)
 
     class Meta:
         model = User
@@ -137,6 +138,7 @@
             "facebook_url",
             "discourse_url",
             "username",
+            "is_newsletter_subscribed",
         )
 
     def __init__(self, *args, **kwargs):

{"golden_diff": "diff --git a/kuma/users/forms.py b/kuma/users/forms.py\n--- a/kuma/users/forms.py\n+++ b/kuma/users/forms.py\n@@ -117,6 +117,7 @@\n             }\n         ),\n     )\n+    is_newsletter_subscribed = forms.BooleanField(required=False)\n \n     class Meta:\n         model = User\n@@ -137,6 +138,7 @@\n             \"facebook_url\",\n             \"discourse_url\",\n             \"username\",\n+            \"is_newsletter_subscribed\",\n         )\n \n     def __init__(self, *args, **kwargs):\n", "issue": "T - Add opt-in checkbox for marketing email to account creation page. \n**Acceptance Criteria**\r\n\r\n- [ ] Add opt-in checkbox for marketing email to account creation page. \r\n- [ ] Upon acct creation opt-in/out value is stored in our database for the given user\r\n\r\n**Design comp**\r\n- see comp [https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/313$](https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3134)\nT - Add opt-in checkbox for marketing email to the Edit Profile Page. \n**Acceptance Criteria**\r\n\r\n- [ ] Add opt-in checkbox for marketing email to the Edit Profile Page\r\n- [ ] Saves user's selection (opt-in/out) to the database\r\n- [ ] Stub out functionality: add user to correct email group in sendinblue (*feedback needed from Kadir)\r\n- [ ] Update 'Publish' button to read 'Save', see comps\r\n- [ ] Update 'Delete Account' to be a button, see comps\r\n- [ ] This functionality should be behind a waffle flag allowing us to turn on once sendinblue is official\r\n\r\n**Comps**\r\n[https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3136](https://app.zenhub.com/workspaces/mdn-dev-5d6ea9fb3fe11605a63cea86/issues/mdn/sprints/3136)\r\n\n", "before_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.utils.translation import gettext_lazy as _\nfrom sundial.forms import TimezoneChoiceField\nfrom sundial.zones import COMMON_GROUPED_CHOICES\n\n\nfrom .constants import USERNAME_CHARACTERS, USERNAME_LEGACY_REGEX, USERNAME_REGEX\nfrom .models import User\nfrom .tasks import send_recovery_email\n\n\nclass UserBanForm(forms.Form):\n    \"\"\"\n    The form used in the view that enables admins to ban users.\n    \"\"\"\n\n    reason = forms.CharField(widget=forms.Textarea)\n\n\nclass UserEditForm(forms.ModelForm):\n    \"\"\"\n    The main form to edit user profile data.\n\n    It dynamically adds a bunch of fields for maintaining information\n    about a user's websites\n    \"\"\"\n\n    timezone = TimezoneChoiceField(\n        label=_(\"Timezone\"),\n        initial=settings.TIME_ZONE,\n        choices=COMMON_GROUPED_CHOICES,\n        required=False,\n    )\n    beta = forms.BooleanField(label=_(\"Beta tester\"), required=False,)\n    username = forms.RegexField(\n        label=_(\"Username\"),\n        regex=USERNAME_REGEX,\n        max_length=30,\n        required=False,\n        error_messages={\"invalid\": USERNAME_CHARACTERS},\n    )\n    twitter_url = forms.CharField(\n        label=_(\"Twitter\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"twitter\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://twitter.com/\",\n                \"data-fa-icon\": \"icon-twitter\",\n            }\n        ),\n    )\n    github_url = forms.CharField(\n        label=_(\"GitHub\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"github\"]],\n        widget=forms.TextInput(\n            attrs={\"placeholder\": \"https://github.com/\", \"data-fa-icon\": \"icon-github\"}\n        ),\n    )\n    is_github_url_public = forms.BooleanField(\n        label=_(\"Display a link to GitHub on my profile\"), required=False\n    )\n    stackoverflow_url = forms.CharField(\n        label=_(\"Stack Overflow\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"stackoverflow\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://stackoverflow.com/users/\",\n                \"data-fa-icon\": \"icon-stackexchange\",\n            }\n        ),\n    )\n    linkedin_url = forms.CharField(\n        label=_(\"LinkedIn\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"linkedin\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://www.linkedin.com/\",\n                \"data-fa-icon\": \"icon-linkedin\",\n            }\n        ),\n    )\n    mozillians_url = forms.CharField(\n        label=_(\"Mozillians\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"mozillians\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://mozillians.org/u/\",\n                \"data-fa-icon\": \"icon-group\",\n            }\n        ),\n    )\n    facebook_url = forms.CharField(\n        label=_(\"Facebook\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"facebook\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://www.facebook.com/\",\n                \"data-fa-icon\": \"icon-facebook\",\n            }\n        ),\n    )\n    discourse_url = forms.CharField(\n        label=_(\"Discourse\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"discourse\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://discourse.mozilla.org/u/\",\n                \"data-fa-icon\": \"icon-discourse\",\n            }\n        ),\n    )\n\n    class Meta:\n        model = User\n        fields = (\n            \"fullname\",\n            \"title\",\n            \"organization\",\n            \"location\",\n            \"locale\",\n            \"timezone\",\n            \"irc_nickname\",\n            \"twitter_url\",\n            \"github_url\",\n            \"is_github_url_public\",\n            \"stackoverflow_url\",\n            \"linkedin_url\",\n            \"mozillians_url\",\n            \"facebook_url\",\n            \"discourse_url\",\n            \"username\",\n        )\n\n    def __init__(self, *args, **kwargs):\n        super(UserEditForm, self).__init__(*args, **kwargs)\n        # in case the username is not changed and the user has a legacy\n        # username we want to disarm the username regex\n        if (\n            \"username\" not in self.changed_data\n            and self.instance\n            and self.instance.has_legacy_username\n        ):\n            self.fields[\"username\"].regex = USERNAME_LEGACY_REGEX\n\n    def clean_username(self):\n        new_username = self.cleaned_data[\"username\"]\n\n        if not new_username:\n            raise forms.ValidationError(_(\"This field cannot be blank.\"))\n\n        if (\n            self.instance is not None\n            and User.objects.exclude(pk=self.instance.pk)\n            .filter(username=new_username)\n            .exists()\n        ):\n            raise forms.ValidationError(_(\"Username already in use.\"))\n        return new_username\n\n\nclass UserRecoveryEmailForm(forms.Form):\n    \"\"\"\n    Send email(s) with an account recovery link.\n\n    Modeled after django.contrib.auth.forms.PasswordResetForm\n    \"\"\"\n\n    email = forms.EmailField(label=_(\"Email\"), max_length=254)\n\n    def save(self, request):\n        \"\"\"\n        Send email(s) with an account recovery link.\n        \"\"\"\n        email = self.cleaned_data[\"email\"]\n\n        # Gather matching active users\n        active_users = User.objects.filter(is_active=True)\n        # Users using email as the primary contact email\n        primary_users = active_users.filter(email__iexact=email)\n        # Users with a matching Persona account\n        personas = active_users.filter(\n            socialaccount__uid__iexact=email, socialaccount__provider=\"persona\"\n        )\n        # Users with that confirmed email\n        confirmed = active_users.filter(emailaddress__email__iexact=email)\n\n        # Send one account recovery email to each matching user\n        user_pks = set()\n        user_pks.update(primary_users.values_list(\"pk\", flat=True))\n        user_pks.update(personas.values_list(\"pk\", flat=True))\n        user_pks.update(confirmed.values_list(\"pk\", flat=True))\n        for user_pk in sorted(user_pks):\n            # TODO figure out why this isn't a .delay() call.\n            # https://bugzilla.mozilla.org/show_bug.cgi?id=1544925\n            send_recovery_email(user_pk, email, request.LANGUAGE_CODE)\n\n\nclass UserDeleteForm(forms.Form):\n    def __init__(self, *args, username, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        choices = {\n            \"keep\": (\n                _(\"Keep my attribution for my page changes (%(username)s)\")\n                % {\"username\": username}\n            ),\n            \"donate\": _('Switch my attribution for my page changes to \"Anonymous\"'),\n        }\n\n        self.fields[\"attributions\"].choices = choices.items()\n\n    attributions = forms.ChoiceField(required=True, widget=forms.widgets.RadioSelect())\n", "path": "kuma/users/forms.py"}], "after_files": [{"content": "from django import forms\nfrom django.conf import settings\nfrom django.utils.translation import gettext_lazy as _\nfrom sundial.forms import TimezoneChoiceField\nfrom sundial.zones import COMMON_GROUPED_CHOICES\n\n\nfrom .constants import USERNAME_CHARACTERS, USERNAME_LEGACY_REGEX, USERNAME_REGEX\nfrom .models import User\nfrom .tasks import send_recovery_email\n\n\nclass UserBanForm(forms.Form):\n    \"\"\"\n    The form used in the view that enables admins to ban users.\n    \"\"\"\n\n    reason = forms.CharField(widget=forms.Textarea)\n\n\nclass UserEditForm(forms.ModelForm):\n    \"\"\"\n    The main form to edit user profile data.\n\n    It dynamically adds a bunch of fields for maintaining information\n    about a user's websites\n    \"\"\"\n\n    timezone = TimezoneChoiceField(\n        label=_(\"Timezone\"),\n        initial=settings.TIME_ZONE,\n        choices=COMMON_GROUPED_CHOICES,\n        required=False,\n    )\n    beta = forms.BooleanField(label=_(\"Beta tester\"), required=False,)\n    username = forms.RegexField(\n        label=_(\"Username\"),\n        regex=USERNAME_REGEX,\n        max_length=30,\n        required=False,\n        error_messages={\"invalid\": USERNAME_CHARACTERS},\n    )\n    twitter_url = forms.CharField(\n        label=_(\"Twitter\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"twitter\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://twitter.com/\",\n                \"data-fa-icon\": \"icon-twitter\",\n            }\n        ),\n    )\n    github_url = forms.CharField(\n        label=_(\"GitHub\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"github\"]],\n        widget=forms.TextInput(\n            attrs={\"placeholder\": \"https://github.com/\", \"data-fa-icon\": \"icon-github\"}\n        ),\n    )\n    is_github_url_public = forms.BooleanField(\n        label=_(\"Display a link to GitHub on my profile\"), required=False\n    )\n    stackoverflow_url = forms.CharField(\n        label=_(\"Stack Overflow\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"stackoverflow\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://stackoverflow.com/users/\",\n                \"data-fa-icon\": \"icon-stackexchange\",\n            }\n        ),\n    )\n    linkedin_url = forms.CharField(\n        label=_(\"LinkedIn\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"linkedin\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://www.linkedin.com/\",\n                \"data-fa-icon\": \"icon-linkedin\",\n            }\n        ),\n    )\n    mozillians_url = forms.CharField(\n        label=_(\"Mozillians\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"mozillians\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://mozillians.org/u/\",\n                \"data-fa-icon\": \"icon-group\",\n            }\n        ),\n    )\n    facebook_url = forms.CharField(\n        label=_(\"Facebook\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"facebook\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://www.facebook.com/\",\n                \"data-fa-icon\": \"icon-facebook\",\n            }\n        ),\n    )\n    discourse_url = forms.CharField(\n        label=_(\"Discourse\"),\n        required=False,\n        validators=[User.WEBSITE_VALIDATORS[\"discourse\"]],\n        widget=forms.TextInput(\n            attrs={\n                \"placeholder\": \"https://discourse.mozilla.org/u/\",\n                \"data-fa-icon\": \"icon-discourse\",\n            }\n        ),\n    )\n    is_newsletter_subscribed = forms.BooleanField(required=False)\n\n    class Meta:\n        model = User\n        fields = (\n            \"fullname\",\n            \"title\",\n            \"organization\",\n            \"location\",\n            \"locale\",\n            \"timezone\",\n            \"irc_nickname\",\n            \"twitter_url\",\n            \"github_url\",\n            \"is_github_url_public\",\n            \"stackoverflow_url\",\n            \"linkedin_url\",\n            \"mozillians_url\",\n            \"facebook_url\",\n            \"discourse_url\",\n            \"username\",\n            \"is_newsletter_subscribed\",\n        )\n\n    def __init__(self, *args, **kwargs):\n        super(UserEditForm, self).__init__(*args, **kwargs)\n        # in case the username is not changed and the user has a legacy\n        # username we want to disarm the username regex\n        if (\n            \"username\" not in self.changed_data\n            and self.instance\n            and self.instance.has_legacy_username\n        ):\n            self.fields[\"username\"].regex = USERNAME_LEGACY_REGEX\n\n    def clean_username(self):\n        new_username = self.cleaned_data[\"username\"]\n\n        if not new_username:\n            raise forms.ValidationError(_(\"This field cannot be blank.\"))\n\n        if (\n            self.instance is not None\n            and User.objects.exclude(pk=self.instance.pk)\n            .filter(username=new_username)\n            .exists()\n        ):\n            raise forms.ValidationError(_(\"Username already in use.\"))\n        return new_username\n\n\nclass UserRecoveryEmailForm(forms.Form):\n    \"\"\"\n    Send email(s) with an account recovery link.\n\n    Modeled after django.contrib.auth.forms.PasswordResetForm\n    \"\"\"\n\n    email = forms.EmailField(label=_(\"Email\"), max_length=254)\n\n    def save(self, request):\n        \"\"\"\n        Send email(s) with an account recovery link.\n        \"\"\"\n        email = self.cleaned_data[\"email\"]\n\n        # Gather matching active users\n        active_users = User.objects.filter(is_active=True)\n        # Users using email as the primary contact email\n        primary_users = active_users.filter(email__iexact=email)\n        # Users with a matching Persona account\n        personas = active_users.filter(\n            socialaccount__uid__iexact=email, socialaccount__provider=\"persona\"\n        )\n        # Users with that confirmed email\n        confirmed = active_users.filter(emailaddress__email__iexact=email)\n\n        # Send one account recovery email to each matching user\n        user_pks = set()\n        user_pks.update(primary_users.values_list(\"pk\", flat=True))\n        user_pks.update(personas.values_list(\"pk\", flat=True))\n        user_pks.update(confirmed.values_list(\"pk\", flat=True))\n        for user_pk in sorted(user_pks):\n            # TODO figure out why this isn't a .delay() call.\n            # https://bugzilla.mozilla.org/show_bug.cgi?id=1544925\n            send_recovery_email(user_pk, email, request.LANGUAGE_CODE)\n\n\nclass UserDeleteForm(forms.Form):\n    def __init__(self, *args, username, **kwargs):\n        super().__init__(*args, **kwargs)\n\n        choices = {\n            \"keep\": (\n                _(\"Keep my attribution for my page changes (%(username)s)\")\n                % {\"username\": username}\n            ),\n            \"donate\": _('Switch my attribution for my page changes to \"Anonymous\"'),\n        }\n\n        self.fields[\"attributions\"].choices = choices.items()\n\n    attributions = forms.ChoiceField(required=True, widget=forms.widgets.RadioSelect())\n", "path": "kuma/users/forms.py"}]}