当前位置: 首页>>代码示例>>Python>>正文


Python Subscription.email_is_subscribed方法代码示例

本文整理汇总了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 }
开发者ID:eyeyunianto,项目名称:satchmo,代码行数:46,代码来源:mailman.py

示例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 }
开发者ID:davemerwin,项目名称:satchmo,代码行数:25,代码来源:mailman.py

示例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)
开发者ID:davemerwin,项目名称:satchmo,代码行数:4,代码来源:mailman.py


注:本文中的models.Subscription.email_is_subscribed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。