本文整理汇总了Python中registration.admin.RegistrationAdmin.resend_activation_email方法的典型用法代码示例。如果您正苦于以下问题:Python RegistrationAdmin.resend_activation_email方法的具体用法?Python RegistrationAdmin.resend_activation_email怎么用?Python RegistrationAdmin.resend_activation_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registration.admin.RegistrationAdmin
的用法示例。
在下文中一共展示了RegistrationAdmin.resend_activation_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_email_send_action_no_sites
# 需要导入模块: from registration.admin import RegistrationAdmin [as 别名]
# 或者: from registration.admin.RegistrationAdmin import resend_activation_email [as 别名]
def test_email_send_action_no_sites(self):
"""
Test re-sending of activation emails via admin action when
``django.contrib.sites`` is not installed; the fallback will
be a ``RequestSite`` instance.
"""
Site._meta.installed = False
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
alice = self.backend.register(_mock_request(),
username='alice',
first_name='alice',
last_name='wonderland',
email='[email protected]',
password1='swordfish')
admin_class.resend_activation_email(_mock_request(),
RegistrationProfile.objects.all())
self.assertEqual(len(mail.outbox), 2) # One on registering, one more on the resend.
RegistrationProfile.objects.filter(user=alice).update(activation_key=RegistrationProfile.ACTIVATED)
admin_class.resend_activation_email(_mock_request(),
RegistrationProfile.objects.all())
self.assertEqual(len(mail.outbox), 2) # No additional email because the account has activated.
Site._meta.installed = True
示例2: test_email_send_action
# 需要导入模块: from registration.admin import RegistrationAdmin [as 别名]
# 或者: from registration.admin.RegistrationAdmin import resend_activation_email [as 别名]
def test_email_send_action(self):
"""
Test re-sending of activation emails via admin action.
"""
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
alice = self.backend.register(
_mock_request(), username="alice", email="[email protected]", password1="swordfish"
)
admin_class.resend_activation_email(_mock_request(), RegistrationProfile.objects.all())
self.assertEqual(len(mail.outbox), 2) # One on registering, one more on the resend.
RegistrationProfile.objects.filter(user=alice).update(activation_key=RegistrationProfile.ACTIVATED)
admin_class.resend_activation_email(_mock_request(), RegistrationProfile.objects.all())
self.assertEqual(len(mail.outbox), 2) # No additional email because the account has activated.