Skip to content

Commit

Permalink
remove email add notification, change notification setting name
Browse files Browse the repository at this point in the history
  • Loading branch information
varun kumar committed Dec 4, 2023
1 parent e0275cf commit 1e1dfaa
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 40 deletions.
2 changes: 1 addition & 1 deletion allauth/account/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def get_reauthentication_methods(self, user):
def send_notification_mail(self, template_prefix, user, context):
from allauth.account.models import EmailAddress

if app_settings.ACCOUNT_EMAIL_NOTIFICATIONS:
if app_settings.EMAIL_NOTIFICATIONS:
context.update(
{
"current_site": get_current_site(self.request),
Expand Down
4 changes: 2 additions & 2 deletions allauth/account/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def REAUTHENTICATION_TIMEOUT(self):
return self._setting("REAUTHENTICATION_TIMEOUT", 300)

@property
def ACCOUNT_EMAIL_NOTIFICATIONS(self):
return self._setting("ACCOUNT_EMAIL_NOTIFICATIONS", False)
def EMAIL_NOTIFICATIONS(self):
return self._setting("EMAIL_NOTIFICATIONS", False)

@property
def REAUTHENTICATION_REQUIRED(self):
Expand Down
18 changes: 1 addition & 17 deletions allauth/account/tests/test_confirm_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,7 @@ def test_confirm_email_with_same_user_logged_in(self):
self.assertEqual(user, resp.wsgi_request.user)


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
def test_notification_on_email_add(auth_client, user, client):
settings.ACCOUNT_MAX_EMAIL_ADDRESSES = 2
client.force_login(user)
response = client.post(
reverse("account_email"),
{"email": "[email protected]", "action_add": ""},
**{
"HTTP_USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
)
assert response.status_code == 302
assert len(mail.outbox) == 2
assert "Email address has been added." in mail.outbox[1].body


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_email_remove(auth_client, user):
secondary = EmailAddress.objects.create(
email="[email protected]", user=user, verified=False, primary=False
Expand Down
4 changes: 2 additions & 2 deletions allauth/account/tests/test_reset_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def _password_set_or_change_redirect(self, urlname, usable_password):
return self.client.get(reverse(urlname))


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_password_change(user_factory, client):
user = user_factory(
email="[email protected]",
Expand All @@ -325,7 +325,7 @@ def test_notification_on_password_change(user_factory, client):
assert "Your password has been changed" in mail.outbox[0].body


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_password_reset(user_factory, client, settings):
user = user_factory(
email="[email protected]",
Expand Down
5 changes: 0 additions & 5 deletions allauth/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,6 @@ def form_valid(self, form):
user=self.request.user,
email_address=email_address,
)
adapter.send_notification_mail(
"account/email/email_added",
self.request.user,
{"email": email_address.email},
)
return super(EmailView, self).form_valid(form)

def post(self, request, *args, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion allauth/mfa/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def wrap(self):
from allauth.mfa.recovery_codes import RecoveryCodes
from allauth.mfa.totp import TOTP

return {self.Type.TOTP: TOTP, self.Type.RECOVERY_CODES: RecoveryCodes,}[
return {
self.Type.TOTP: TOTP,
self.Type.RECOVERY_CODES: RecoveryCodes,
}[
self.type
](self)

Expand Down
8 changes: 4 additions & 4 deletions allauth/mfa/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_activate_totp_with_unverified_email(
}


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_activate_totp_success(
auth_client, totp_validation_bypass, user, reauthentication_bypass
):
Expand Down Expand Up @@ -286,7 +286,7 @@ def test_cannot_deactivate_totp(auth_client, user_with_totp, user_password):
}


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_mfa_activate_totp(
auth_client, reauthentication_bypass, totp_validation_bypass
):
Expand All @@ -305,7 +305,7 @@ def test_notification_on_mfa_activate_totp(
assert "Totp has been activated." in mail.outbox[0].body


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_mfa_deactivate_totp(
auth_client, user_with_totp, user_password
):
Expand All @@ -322,7 +322,7 @@ def test_notification_on_mfa_deactivate_totp(
assert "Totp has been deactivated." in mail.outbox[0].body


@patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
@patch("allauth.account.app_settings.EMAIL_NOTIFICATIONS", True)
def test_notification_on_authenticator_reset(
auth_client, user_with_recovery_codes, user_password
):
Expand Down
4 changes: 0 additions & 4 deletions allauth/templates/account/email/email_added_message.txt

This file was deleted.

4 changes: 0 additions & 4 deletions allauth/templates/account/email/email_added_subject.txt

This file was deleted.

0 comments on commit 1e1dfaa

Please sign in to comment.