Skip to content

Commit

Permalink
remove social_ prefix from templates, use emailaddress.email, remove …
Browse files Browse the repository at this point in the history
…comments and print
  • Loading branch information
varun kumar committed Dec 3, 2023
1 parent 810fb47 commit e0275cf
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 26 deletions.
14 changes: 0 additions & 14 deletions allauth/account/tests/test_change_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,3 @@ def test_dont_lookup_invalid_email(auth_client, email, did_look_up):
{"action_remove": "", "email": email},
)
assert gfu_mock.called == did_look_up


# @patch("allauth.account.app_settings.ACCOUNT_EMAIL_NOTIFICATIONS", True)
# def test_notification_on_email_change(user, client, settings):
# secondary = EmailAddress.objects.create(
# email="[email protected]", user=user, verified=False, primary=True
# )
# resp = client.post(
# reverse("account_email"),
# {"action_primary": "", "email": secondary.email},
# )
# assert resp.status_code == 302
# assert len(mail.outbox) == 1
# assert "Your email has been changed.{" in mail.outbox[0].body
1 change: 0 additions & 1 deletion allauth/account/tests/test_reset_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ def test_notification_on_password_change(user_factory, client):
}
)
assert len(mail.outbox) == 1
print(mail.outbox[0].body)
assert "Your password has been changed" in mail.outbox[0].body


Expand Down
10 changes: 6 additions & 4 deletions allauth/account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ def form_valid(self, form):
email_address=email_address,
)
adapter.send_notification_mail(
"account/email/email_added", self.request.user, {"email": email_address}
"account/email/email_added",
self.request.user,
{"email": email_address.email},
)
return super(EmailView, self).form_valid(form)

Expand Down Expand Up @@ -570,7 +572,7 @@ def _action_remove(self, request, *args, **kwargs):
adapter.send_notification_mail(
"account/email/email_removed",
request.user,
{"email": email_address},
{"email": email_address.email},
)
return HttpResponseRedirect(self.get_success_url())

Expand Down Expand Up @@ -619,8 +621,8 @@ def _action_primary(self, request, *args, **kwargs):
"account/email/email_changed",
request.user,
{
"from_email_address": from_email_address,
"to_email_address": email_address,
"from_emailaddress": from_email_address.email,
"to_emailaddress": email_address.email,
},
)
return HttpResponseRedirect(self.get_success_url())
Expand Down
1 change: 0 additions & 1 deletion allauth/mfa/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def test_activate_totp_success(
**{"HTTP_USER_AGENT": "test"},
)
assert len(mail.outbox) == 1
print(mail.outbox[0].subject, mail.outbox[0].body)
assert resp["location"] == reverse("mfa_view_recovery_codes")
assert Authenticator.objects.filter(
user=user, type=Authenticator.Type.TOTP
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def get_app(self, request, provider, client_id=None):
elif len(apps) == 0:
raise SocialApp.DoesNotExist()
return apps[0]

def send_notification_mail(self, *args, **kwargs):
return get_account_adapter().send_notification_mail(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ def save(self):
sender=SocialAccount, request=self.request, socialaccount=account
)
get_adapter().send_notification_mail(
"socialaccount/email/social_account_disconnected", self.request.user, {}
"socialaccount/email/account_disconnected", self.request.user, {}
)
5 changes: 1 addition & 4 deletions allauth/socialaccount/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def connect(self, request, user):
)

get_adapter().send_notification_mail(
"socialaccount/email/social_account_added", self.user, {}
"socialaccount/email/account_added", self.user, {}
)

def serialize(self):
Expand Down Expand Up @@ -303,9 +303,6 @@ def _lookup_by_socialaccount(self):
signals.social_account_updated.send(
sender=SocialLogin, request=context.request, sociallogin=self
)
get_adapter().send_notification_mail(
"socialaccount/email/social_account_updated", self.user, {}
)
# Update token
if app_settings.STORE_TOKENS and self.token:
assert not self.token.pk
Expand Down

0 comments on commit e0275cf

Please sign in to comment.