本文整理汇总了Python中models.Subscription.email_is_subscribed方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.email_is_subscribed方法的具体用法?Python Subscription.email_is_subscribed怎么用?Python Subscription.email_is_subscribed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Subscription
的用法示例。
在下文中一共展示了Subscription.email_is_subscribed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_contact
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import email_is_subscribed [as 别名]
def update_contact(contact, subscribe, attributes={}):
email = contact.email
current = Subscription.email_is_subscribed(email)
attributesChanged = False
sub = None
if attributes:
sub, created = Subscription.objects.get_or_create(email=email)
if created:
attributesChanged = True
else:
oldAttr = [(a.name,a.value) for a in sub.attributes.all()]
oldAttr.sort()
sub.update_attributes(attributes)
newAttr = [(a.name,a.value) for a in sub.attributes.all()]
newAttr.sort()
if not created:
attributesChanged = oldAttr != newAttr
if current == subscribe:
if subscribe:
if attributesChanged:
result = _("Updated subscription for %(email)s.")
else:
result = _("Already subscribed %(email)s.")
else:
result = _("Already removed %(email)s.")
else:
if not sub:
sub, created = Subscription.objects.get_or_create(email=email)
sub.subscribed = subscribe
sub.save()
if subscribe:
mailman_add(contact)
result = _("Subscribed: %(email)s")
else:
mailman_remove(contact)
result = _("Unsubscribed: %(email)s")
return result % { 'email' : email }
示例2: update_contact
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import email_is_subscribed [as 别名]
def update_contact(contact, subscribe):
email = contact.email
current = Subscription.email_is_subscribed(email)
if current == subscribe:
if subscribe:
result = _("Already subscribed %(email)s.")
else:
result = _("Already removed %(email)s.")
else:
sub, created = Subscription.objects.get_or_create(email=email)
sub.subscribed = subscribe
sub.save()
if subscribe:
mailman_add(contact)
result = _("Subscribed: %(email)s")
else:
mailman_remove(contact)
result = _("Unsubscribed: %(email)s")
return result % { 'email' : email }
示例3: is_subscribed
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import email_is_subscribed [as 别名]
def is_subscribed(contact):
return Subscription.email_is_subscribed(contact.email)