本文整理汇总了Python中registration.admin.RegistrationAdmin类的典型用法代码示例。如果您正苦于以下问题:Python RegistrationAdmin类的具体用法?Python RegistrationAdmin怎么用?Python RegistrationAdmin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RegistrationAdmin类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_force_activate_users_action
def test_force_activate_users_action(self):
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
self.backend.register(username='bob', email='[email protected]', request=self.mock_request)
admin_class.force_activate_users(None, RegistrationProfile.objects.all())
self.assertEqual(RegistrationProfile.objects.count(), 0)
示例2: test_email_send_action_no_sites
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
示例3: test_resend_acceptance_email_action
def test_resend_acceptance_email_action(self):
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
self.backend.register(username='bob', email='[email protected]', request=self.mock_request)
admin_class.resend_acceptance_email(None, RegistrationProfile.objects.all())
# one for registration, one for resend
self.assertEqual(len(mail.outbox), 2)
示例4: test_get_inline_instances_with_default_supplements
def test_get_inline_instances_with_default_supplements(self):
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
# Prevent caching
if hasattr(admin_class.backend, '_supplement_class_cache'):
delattr(admin_class.backend, '_supplement_class_cache')
inline_instances = admin_class.get_inline_instances(self.mock_request, None)
self.assertEqual(len(inline_instances), 1)
示例5: test_reject_users_action
def test_reject_users_action(self):
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
self.backend.register(username='bob', email='[email protected]', request=self.mock_request)
admin_class.reject_users(None, RegistrationProfile.objects.all())
for profile in RegistrationProfile.objects.all():
self.assertEqual(profile.status, 'rejected')
self.assertEqual(profile.activation_key, None)
示例6: test_activation_action
def test_activation_action(self):
"""
Test manual activation of users view admin action.
"""
admin_class = RegistrationAdmin(RegistrationProfile, admin.site)
alice = self.backend.register(
_mock_request(), username="alice", email="[email protected]", password1="swordfish"
)
admin_class.activate_users(_mock_request(), RegistrationProfile.objects.all())
self.failUnless(User.objects.get(username="alice").is_active)
示例7: test_activation_action
def test_activation_action(self):
"""
Test manual activation of users view admin action.
"""
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.activate_users(_mock_request(),
RegistrationProfile.objects.all())
self.failUnless(User.objects.get(username='alice').is_active)
示例8: test_email_send_action
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.