本文整理汇总了Python中newsletter.models.Subscription.send_activation_email方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.send_activation_email方法的具体用法?Python Subscription.send_activation_email怎么用?Python Subscription.send_activation_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newsletter.models.Subscription
的用法示例。
在下文中一共展示了Subscription.send_activation_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MailingTestCase
# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import send_activation_email [as 别名]
class MailingTestCase(MailTestCase):
def get_newsletter_kwargs(self):
""" Returns the keyword arguments for instanciating the newsletter. """
return {
'title': 'Test newsletter',
'slug': 'test-newsletter',
'sender': 'Test Sender',
'email': '[email protected]'
}
def setUp(self):
self.n = Newsletter(**self.get_newsletter_kwargs())
self.n.save()
self.n.site = get_default_sites()
self.m = Message(title='Test message',
newsletter=self.n,
slug='test-message')
self.m.save()
self.s = Subscription(
name='Test Name', email='[email protected]',
newsletter=self.n, subscribed=True
)
self.s.save()
def send_email(self, action):
assert action in ACTIONS + ('message', ), 'Unknown action: %s' % action
if action == 'message':
# Create submission
sub = Submission.from_message(self.m)
sub.prepared = True
sub.publish_date = now() - timedelta(seconds=1)
sub.save()
# Send message email
Submission.submit_queue()
else:
self.s.send_activation_email(action)
示例2: form_valid
# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import send_activation_email [as 别名]
def form_valid(self, form):
newsletter = self.get_services_newsletter()
email = form.cleaned_data['email']
try:
subscription = Subscription.objects.get(email_field=email, newsletter=newsletter)
except Subscription.DoesNotExist:
subscription = Subscription()
subscription.email = form.cleaned_data['email']
subscription.name = form.cleaned_data['name']
subscription.newsletter = self.get_services_newsletter()
subscription.save()
subscription.send_activation_email(action='subscribe')
messages.success(self.request, u'Вы подписались на уведомления о новых акциях стоматологического центра "Рябина"!')
else:
if subscription.subscribed:
messages.success(self.request, u'Вы уже подписаны на уведомления о новых акциях стоматологического центра "Рябина"!')
else:
subscription.send_activation_email(action='subscribe')
messages.success(self.request, u'Мы выслали вам письмо активации на уведомления о новых акциях стоматологического центра "Рябина"!')
return HttpResponseRedirect(self.get_success_url())