本文整理汇总了Python中mozillians.users.tasks.update_basket_task.delay函数的典型用法代码示例。如果您正苦于以下问题:Python delay函数的具体用法?Python delay怎么用?Python delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_member
def add_member(self, userprofile, status=GroupMembership.MEMBER):
"""
Add a user to this group. Optionally specify status other than member.
If user is already in the group with the given status, this is a no-op.
If user is already in the group with a different status, their status will
be updated.
"""
defaults = dict(status=status, date_joined=now())
membership, created = GroupMembership.objects.get_or_create(
userprofile=userprofile, group=self, defaults=defaults
)
if created:
if status == GroupMembership.MEMBER:
# Joined
update_basket_task.delay(userprofile.id)
elif not created and membership.status != status:
# Status changed
old_status = membership.status
membership.status = status
membership.save()
update_basket_task.delay(userprofile.id)
if (old_status, status) == (GroupMembership.PENDING, GroupMembership.MEMBER):
# Request accepted
email_membership_change.delay(self.pk, userprofile.user.pk, old_status, status)
示例2: add_member
def add_member(self, userprofile, status=GroupMembership.MEMBER):
"""
Add a user to this group. Optionally specify status other than member.
If user is already in the group with the given status, this is a no-op.
If user is already in the group with a different status, their status will
be updated if the change is a promotion. Otherwise, their status will not change.
"""
defaults = dict(status=status,
date_joined=now())
membership, created = GroupMembership.objects.get_or_create(userprofile=userprofile,
group=self,
defaults=defaults)
if created:
if status == GroupMembership.MEMBER:
# Joined
# Group is functional area, we want to sent this update to Basket
if self.functional_area:
update_basket_task.delay(userprofile.id)
else:
if membership.status != status:
# Status changed
old_status = membership.status
membership.status = status
if (old_status, status) == (GroupMembership.PENDING, GroupMembership.MEMBER):
# Request accepted
membership.save()
if self.functional_area:
# Group is functional area, we want to sent this update to Basket.
update_basket_task.delay(userprofile.id)
email_membership_change.delay(self.pk, userprofile.user.pk, old_status, status)
示例3: remove_member
def remove_member(self, userprofile, send_email=True):
membership = GroupMembership.objects.get(group=self, userprofile=userprofile)
old_status = membership.status
membership.delete()
update_basket_task.delay(userprofile.id)
if old_status == GroupMembership.PENDING and send_email:
# Request denied
email_membership_change.delay(self.pk, userprofile.user.pk, old_status, None)
示例4: toggle_group_subscription
def toggle_group_subscription(request, url):
"""Toggle the current user's membership of a group."""
group = get_object_or_404(Group, url=url)
profile = request.user.userprofile
# We don't operate on system groups using this view.
if not group.system:
if profile.groups.filter(id=group.id).exists():
profile.groups.remove(group)
else:
profile.groups.add(group)
update_basket_task.delay(profile.id)
return redirect(reverse('groups:show_group', args=[group.url]))
示例5: remove_member
def remove_member(self, userprofile, send_email=True):
try:
membership = GroupMembership.objects.get(group=self, userprofile=userprofile)
except GroupMembership.DoesNotExist:
return
old_status = membership.status
membership.delete()
# If group is functional area, we want to sent this update to Basket
if self.functional_area:
update_basket_task.delay(userprofile.id)
if old_status == GroupMembership.PENDING and send_email:
# Request denied
email_membership_change.delay(self.pk, userprofile.user.pk,
old_status, None)
示例6: add_member
def add_member(self, userprofile, status=GroupMembership.MEMBER):
"""
Add a user to this group. Optionally specify status other than member.
If user is already in the group with the given status, this is a no-op.
If user is already in the group with a different status, their status will
be updated if the change is a promotion. Otherwise, their status will not change.
If the group in question is the NDA group, also add the user to the NDA newsletter.
"""
defaults = dict(status=status, date_joined=now())
membership, created = GroupMembership.objects.get_or_create(userprofile=userprofile,
group=self,
defaults=defaults)
if membership.status != status:
# Status changed
# The only valid status change states are:
# PENDING to MEMBER
# PENDING to PENDING_TERMS
# PENDING_TERMS to MEMBER
old_status = membership.status
membership.status = status
statuses = [(GroupMembership.PENDING, GroupMembership.MEMBER),
(GroupMembership.PENDING, GroupMembership.PENDING_TERMS),
(GroupMembership.PENDING_TERMS, GroupMembership.MEMBER)]
if (old_status, status) in statuses:
# Status changed
membership.save()
if membership.status in [GroupMembership.PENDING, GroupMembership.MEMBER]:
email_membership_change.delay(self.pk, userprofile.user.pk, old_status, status)
# Since there is no demotion, we can check if the new status is MEMBER and
# subscribe the user to the NDA newsletter if the group is NDA
if self.name == settings.NDA_GROUP and status == GroupMembership.MEMBER:
update_basket_task.delay(userprofile.id, [settings.BASKET_NDA_NEWSLETTER])
示例7: update_basket
def update_basket(sender, instance, **kwargs):
update_basket_task.delay(instance.id)
示例8: update_basket
def update_basket(sender, instance, **kwargs):
if instance.is_vouched:
update_basket_task.delay(instance.id)
elif instance.basket_token:
unsubscribe_from_basket_task.delay(instance.email, instance.basket_token)
示例9: update_basket
def update_basket(sender, instance, **kwargs):
newsletters = [settings.BASKET_VOUCHED_NEWSLETTER]
if instance.is_vouched:
update_basket_task.delay(instance.id, newsletters)
elif instance.basket_token:
unsubscribe_from_basket_task.delay(instance.email, instance.basket_token, newsletters)