本文整理汇总了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"
示例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()
示例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()