diff --git a/allauth/account/adapter.py b/allauth/account/adapter.py index 96227c9391..891c10cc2c 100644 --- a/allauth/account/adapter.py +++ b/allauth/account/adapter.py @@ -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), diff --git a/allauth/account/app_settings.py b/allauth/account/app_settings.py index 5e9f6cc3a4..e27251bbb1 100644 --- a/allauth/account/app_settings.py +++ b/allauth/account/app_settings.py @@ -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): diff --git a/allauth/account/tests/test_confirm_email.py b/allauth/account/tests/test_confirm_email.py index 202c460099..a34f3348b1 100644 --- a/allauth/account/tests/test_confirm_email.py +++ b/allauth/account/tests/test_confirm_email.py @@ -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": "test_email@test.com", "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="secondary@email.org", user=user, verified=False, primary=False diff --git a/allauth/account/tests/test_reset_password.py b/allauth/account/tests/test_reset_password.py index 16136ce53c..b75e406d14 100644 --- a/allauth/account/tests/test_reset_password.py +++ b/allauth/account/tests/test_reset_password.py @@ -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="john.doe@test.com", @@ -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="john.doe@test.com", diff --git a/allauth/account/views.py b/allauth/account/views.py index e6fe08d82b..474d22616d 100644 --- a/allauth/account/views.py +++ b/allauth/account/views.py @@ -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): diff --git a/allauth/mfa/models.py b/allauth/mfa/models.py index 2e6012b934..535292f201 100644 --- a/allauth/mfa/models.py +++ b/allauth/mfa/models.py @@ -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) diff --git a/allauth/mfa/tests/test_views.py b/allauth/mfa/tests/test_views.py index 8a972ab43f..4911ddbdc3 100644 --- a/allauth/mfa/tests/test_views.py +++ b/allauth/mfa/tests/test_views.py @@ -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 ): @@ -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 ): @@ -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 ): @@ -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 ): diff --git a/allauth/templates/account/email/email_added_message.txt b/allauth/templates/account/email/email_added_message.txt deleted file mode 100644 index 91be7a4d2a..0000000000 --- a/allauth/templates/account/email/email_added_message.txt +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "account/email/base_notification.txt" %} -{% load i18n %} - -{% block notification_message %}{% blocktrans %}Email address has been added.{% endblocktrans %}{% endblock notification_message %} diff --git a/allauth/templates/account/email/email_added_subject.txt b/allauth/templates/account/email/email_added_subject.txt deleted file mode 100644 index d752bc9e03..0000000000 --- a/allauth/templates/account/email/email_added_subject.txt +++ /dev/null @@ -1,4 +0,0 @@ -{% load i18n %} -{% autoescape off %} -{% blocktrans %}Email Added{% endblocktrans %} -{% endautoescape %}