本文整理汇总了Python中mkt.webapps.tasks.index_webapps.delay函数的典型用法代码示例。如果您正苦于以下问题:Python delay函数的具体用法?Python delay怎么用?Python delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self, addon, commit=True):
if (self.cleaned_data.get('DELETE') and
'upload_hash' not in self.changed_data and self.promo.id):
self.promo.delete()
elif self.promo and 'upload_hash' in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get('upload_hash'):
super(AdminSettingsForm, self).save(addon, True)
updates = {
'vip_app': self.cleaned_data.get('vip_app'),
'priority_review': self.cleaned_data.get('priority_review'),
}
contact = self.cleaned_data.get('mozilla_contact')
if contact is not None:
updates['mozilla_contact'] = contact
addon.update(**updates)
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get('banner_regions')
geodata.banner_message = self.cleaned_data.get('banner_message')
geodata.save()
uses_flash = self.cleaned_data.get('flash')
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例2: save
def save(self, addon, commit=True):
if (self.cleaned_data.get('DELETE') and
'upload_hash' not in self.changed_data and self.promo.id):
self.promo.delete()
elif self.promo and 'upload_hash' in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get('upload_hash'):
super(AdminSettingsForm, self).save(addon, True)
updates = {
'vip_app': self.cleaned_data.get('vip_app'),
}
contact = self.cleaned_data.get('mozilla_contact')
if contact is not None:
updates['mozilla_contact'] = contact
if (self.cleaned_data.get('priority_review') and
not addon.priority_review):
# addon.priority_review gets updated within prioritize_app().
prioritize_app(addon, self.request.user)
else:
updates['priority_review'] = self.cleaned_data.get(
'priority_review')
addon.update(**updates)
index_webapps.delay([addon.id])
return addon
示例3: handle
def handle(self, *args, **kw):
apps = kw.get('apps')
if not apps:
raise CommandError('The --apps option is required.')
ids = [int(a.strip()) for a in apps.split(',')]
index_webapps.delay(ids)
示例4: save
def save(self, addon, commit=True):
if self.cleaned_data.get("DELETE") and "upload_hash" not in self.changed_data and self.promo.id:
self.promo.delete()
elif self.promo and "upload_hash" in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get("upload_hash"):
super(AdminSettingsForm, self).save(addon, True)
updates = {
"vip_app": self.cleaned_data.get("vip_app"),
"priority_review": self.cleaned_data.get("priority_review"),
}
contact = self.cleaned_data.get("mozilla_contact")
if contact is not None:
updates["mozilla_contact"] = contact
addon.update(**updates)
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get("banner_regions")
geodata.banner_message = self.cleaned_data.get("banner_message")
geodata.save()
uses_flash = self.cleaned_data.get("flash")
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例5: save
def save(self, addon, commit=True):
if (self.cleaned_data.get('DELETE') and
'upload_hash' not in self.changed_data and self.promo.id):
self.promo.delete()
elif self.promo and 'upload_hash' in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get('upload_hash'):
super(AdminSettingsForm, self).save(addon, True)
contact = self.cleaned_data.get('mozilla_contact')
if contact:
addon.update(mozilla_contact=contact)
tags = self.cleaned_data.get('tags')
if tags:
tags_new = self.cleaned_data['tags']
tags_old = [slugify(t, spaces=True) for t in self.get_tags(addon)]
add_tags = set(tags_new) - set(tags_old)
del_tags = set(tags_old) - set(tags_new)
# Add new tags.
for t in add_tags:
Tag(tag_text=t).save_tag(addon)
# Remove old tags.
for t in del_tags:
Tag(tag_text=t).remove_tag(addon)
# Content ratings.
ratings = self.cleaned_data.get('app_ratings')
if ratings:
ratings = [ALL_RATINGS()[int(i)] for i in ratings]
# Delete content ratings with ratings body not in new set.
r_bodies = set([rating.ratingsbody.id for rating in ratings])
addon.content_ratings.exclude(ratings_body__in=r_bodies).delete()
# Set content ratings, takes {<ratingsbody class>: <rating class>}.
addon.set_content_ratings(
dict((rating.ratingsbody, rating) for rating in ratings))
else:
addon.content_ratings.all().delete()
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get('banner_regions')
geodata.banner_message = self.cleaned_data.get('banner_message')
geodata.save()
toggle_game(addon)
uses_flash = self.cleaned_data.get('flash')
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例6: set_apps
def set_apps(self, new_apps):
"""
Passed a list of app IDs, will remove all existing members on the
collection and create new ones for each of the passed apps, in order.
"""
self.remove_apps()
for app_id in new_apps:
self.add_app(Webapp.objects.get(pk=app_id))
index_webapps.delay(new_apps)
示例7: save
def save(self, addon, commit=True):
if (self.cleaned_data.get('DELETE') and
'upload_hash' not in self.changed_data and self.promo.id):
self.promo.delete()
elif self.promo and 'upload_hash' in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get('upload_hash'):
super(AdminSettingsForm, self).save(addon, True)
contact = self.cleaned_data.get('mozilla_contact')
if contact:
addon.update(mozilla_contact=contact)
tags = self.cleaned_data.get('tags')
if tags:
tags_new = self.cleaned_data['tags']
tags_old = [slugify(t, spaces=True) for t in self.get_tags(addon)]
add_tags = set(tags_new) - set(tags_old)
del_tags = set(tags_old) - set(tags_new)
# Add new tags.
for t in add_tags:
Tag(tag_text=t).save_tag(addon)
# Remove old tags.
for t in del_tags:
Tag(tag_text=t).remove_tag(addon)
ratings = self.cleaned_data.get('app_ratings')
if ratings:
before = set(addon.content_ratings.filter(rating__in=ratings)
.values_list('rating', flat=True))
after = set(int(r) for r in ratings)
addon.content_ratings.exclude(rating__in=after).delete()
new_ratings = after - before
for i in new_ratings:
rb = ALL_RATINGS()[i]
addon.content_ratings.create(rating=rb.id,
ratings_body=rb.ratingsbody.id)
else:
addon.content_ratings.all().delete()
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get('banner_regions')
geodata.banner_message = self.cleaned_data.get('banner_message')
geodata.save()
toggle_game(addon)
uses_flash = self.cleaned_data.get('flash')
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例8: remove_app
def remove_app(self, app):
"""
Remove the passed app from this collection, returning a boolean
indicating whether a successful deletion took place.
"""
try:
membership = self.membership_class.objects.get(obj=self, app=app)
except self.membership_class.DoesNotExist:
return False
else:
membership.delete()
index_webapps.delay([app.pk])
return True
示例9: reorder
def reorder(self, new_order):
"""
Passed a list of app IDs, e.g.
[18, 24, 9]
will change the order of each item in the collection to match the
passed order. A ValueError will be raised if each app in the
collection is not included in the ditionary.
"""
if set(a.pk for a in self.apps()) != set(new_order):
raise ValueError("Not all apps included")
for order, pk in enumerate(new_order):
CollectionMembership.objects.get(collection=self, app_id=pk).update(order=order)
index_webapps.delay(new_order)
示例10: add_app
def add_app(self, app, order=None):
"""
Add an app to this collection. If specified, the app will be created
with the specified `order`. If not, it will be added to the end of the
collection.
"""
qs = CollectionMembership.objects.filter(collection=self)
if order is None:
aggregate = qs.aggregate(models.Max("order"))["order__max"]
order = aggregate + 1 if aggregate is not None else 0
rval = CollectionMembership.objects.create(collection=self, app=app, order=order)
# Help django-cache-machine: it doesn't like many 2 many relations,
# the cache is never invalidated properly when adding a new object.
CollectionMembership.objects.invalidate(*qs)
index_webapps.delay([app.pk])
return rval
示例11: add_app
def add_app(self, app, order=None):
"""
Add an app to this collection. If specified, the app will be created
with the specified `order`. If not, it will be added to the end of the
collection.
"""
qs = self.membership_class.objects.filter(obj=self)
if order is None:
aggregate = qs.aggregate(models.Max('order'))['order__max']
order = aggregate + 1 if aggregate is not None else 0
rval = self.membership_class.objects.create(obj=self, app=app,
order=order)
index_webapps.delay([app.pk])
return rval
示例12: reorder
def reorder(self, new_order):
"""
Passed a list of app IDs, e.g.
[18, 24, 9]
will change the order of each item in the collection to match the
passed order. A ValueError will be raised if each app in the
collection is not included in the ditionary.
"""
existing_pks = self.apps().no_cache().values_list('pk', flat=True)
if set(existing_pks) != set(new_order):
raise ValueError('Not all apps included')
for order, pk in enumerate(new_order):
CollectionMembership.objects.get(collection=self,
app_id=pk).update(order=order)
index_webapps.delay(new_order)
示例13: save
def save(self, addon, commit=True):
if (self.cleaned_data.get('DELETE') and
'upload_hash' not in self.changed_data and self.promo.id):
self.promo.delete()
elif self.promo and 'upload_hash' in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get('upload_hash'):
super(AdminSettingsForm, self).save(addon, True)
updates = {
'vip_app': self.cleaned_data.get('vip_app'),
'priority_review': self.cleaned_data.get('priority_review'),
}
contact = self.cleaned_data.get('mozilla_contact')
if contact is not None:
updates['mozilla_contact'] = contact
addon.update(**updates)
tags_new = self.cleaned_data['tags']
tags_old = [slugify(t, spaces=True) for t in self.get_tags(addon)]
add_tags = set(tags_new) - set(tags_old)
del_tags = set(tags_old) - set(tags_new)
# Add new tags.
for t in add_tags:
Tag(tag_text=t).save_tag(addon)
# Remove old tags.
for t in del_tags:
Tag(tag_text=t).remove_tag(addon)
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get('banner_regions')
geodata.banner_message = self.cleaned_data.get('banner_message')
geodata.save()
uses_flash = self.cleaned_data.get('flash')
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例14: save
def save(self, addon, commit=True):
if self.cleaned_data.get("DELETE") and "upload_hash" not in self.changed_data and self.promo.id:
self.promo.delete()
elif self.promo and "upload_hash" in self.changed_data:
self.promo.delete()
elif self.cleaned_data.get("upload_hash"):
super(AdminSettingsForm, self).save(addon, True)
updates = {
"vip_app": self.cleaned_data.get("vip_app"),
"priority_review": self.cleaned_data.get("priority_review"),
}
contact = self.cleaned_data.get("mozilla_contact")
if contact is not None:
updates["mozilla_contact"] = contact
addon.update(**updates)
tags_new = self.cleaned_data["tags"]
tags_old = [slugify(t, spaces=True) for t in self.get_tags(addon)]
add_tags = set(tags_new) - set(tags_old)
del_tags = set(tags_old) - set(tags_new)
# Add new tags.
for t in add_tags:
Tag(tag_text=t).save_tag(addon)
# Remove old tags.
for t in del_tags:
Tag(tag_text=t).remove_tag(addon)
geodata = addon.geodata
geodata.banner_regions = self.cleaned_data.get("banner_regions")
geodata.banner_message = self.cleaned_data.get("banner_message")
geodata.save()
uses_flash = self.cleaned_data.get("flash")
af = addon.get_latest_file()
if af is not None:
af.update(uses_flash=bool(uses_flash))
index_webapps.delay([addon.id])
return addon
示例15: add_app_grouped
def add_app_grouped(self, app, group, order=None):
"""
Add an app to this collection, as a member of the passed `group`.
If specified, the app will be created with the specified `order`. If
not, it will be added to the end of the collection.
"""
qs = self.membership_class.objects.filter(obj=self)
if order is None:
aggregate = qs.aggregate(models.Max('order'))['order__max']
order = aggregate + 1 if aggregate is not None else 0
rval = self.membership_class.objects.create(obj_id=self.id, app_id=app,
group=group, order=order)
# Help django-cache-machine: it doesn't like many 2 many relations,
# the cache is never invalidated properly when adding a new object.
self.membership_class.objects.invalidate(*qs)
index_webapps.delay([app])
return rval