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


Python Subscription.subscribe方法代码示例

本文整理汇总了Python中newsletter.models.Subscription.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.subscribe方法的具体用法?Python Subscription.subscribe怎么用?Python Subscription.subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在newsletter.models.Subscription的用法示例。


在下文中一共展示了Subscription.subscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: importUsers

# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import subscribe [as 别名]
def importUsers():

    try:
        newsl = Newsletter.objects.get(slug='emif-catalogue-newsletter')


        users = User.objects.all()

        for user in users:
            try:
                subscription = Subscription.objects.get(user=user,  newsletter=newsl)

            except Subscription.DoesNotExist:
                # create subscription if doesnt exist yet
                user_sub = Subscription(user=user,  newsletter=newsl)

                user_sub.subscribe()

                user_sub.save()

                print "-- Created subscription for emif newsletter to user "+str(user.username)

                pass

    except Newsletter.DoesNotExist:
        print "Problem finding default newsletter for emif"
开发者ID:bioinformatics-ua,项目名称:montra,代码行数:28,代码来源:addNewsletterExistingUsers.py

示例2: add_invited

# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import subscribe [as 别名]
def add_invited(user):
    print "ADD INVITED SUBSCRIPTIONS"
    ## Add to subscription list

    # get newsletter
    try:
        newsl = Newsletter.objects.get(slug='emif-catalogue-newsletter')

        # create subscription
        user_sub = Subscription(user=user,  newsletter=newsl)

        user_sub.subscribe()

        user_sub.save()

    except Newsletter.DoesNotExist:
        print "Problem registering new user to emif default newsletter"

    # add invited dbs if any
    sps = InvitePending.objects.filter(email=user.email)

    for sp in sps:

        fingerprint = sp.fingerprint

        fingerprint.save()

        fingerprint.shared.add(user)

        sp.delete()

        # must reindex, because databases lists come from solr, to update user_t
        fingerprint.indexFingerprint()
开发者ID:bastiao,项目名称:catalogue,代码行数:35,代码来源:models.py

示例3: setNewsletterSubs

# 需要导入模块: from newsletter.models import Subscription [as 别名]
# 或者: from newsletter.models.Subscription import subscribe [as 别名]
    def setNewsletterSubs(self, new_status):
        newsl = self.getNewsletter()

        newsl_sub = None
        try:
            newsl_sub = Subscription.objects.get(user=self.user,  newsletter=newsl)
        except Subscription.DoesNotExist:
            newsl_sub = Subscription(user=self.user, newsletter = newsl)

        if(new_status):
            newsl_sub.subscribe()
        else:
            newsl_sub.unsubscribe()

        newsl_sub.save()
开发者ID:bastiao,项目名称:catalogue,代码行数:17,代码来源:models.py


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