本文整理汇总了Python中mkt.webapps.tasks.update_manifests函数的典型用法代码示例。如果您正苦于以下问题:Python update_manifests函数的具体用法?Python update_manifests怎么用?Python update_manifests使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_manifests函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_manifest_fetch_3x_fail
def test_manifest_fetch_3x_fail(self, retry, fetch):
def die(self):
raise RuntimeError()
fetch.side_effect = die
update_manifests(ids=(self.addon.pk,), retries={self.addon.pk: 2})
assert not retry.called
assert RereviewQueue.objects.filter(addon=self.addon).exists()
开发者ID:dimonov,项目名称:zamboni,代码行数:7,代码来源:test_tasks.py
示例2: test_manifest_fetch_4th_attempt
def test_manifest_fetch_4th_attempt(self, notify, retry, fetch):
fetch.side_effect = RuntimeError
update_manifests(ids=(self.addon.pk,), retries={self.addon.pk: 3})
# We already tried 3 times before, this is the 4th and last attempt,
# we shouldn't retry anymore, instead we should just add the app to
# the re-review queue. We shouldn't notify the developer either at this
# step, it should have been done before already.
assert not notify.called
assert not retry.called
assert RereviewQueue.objects.filter(addon=self.addon).exists()
开发者ID:AALEKH,项目名称:zamboni,代码行数:10,代码来源:test_tasks.py
示例3: test_manifest_fetch_fail
def test_manifest_fetch_fail(self, retry, fetch):
later = datetime.datetime.now() + datetime.timedelta(seconds=3600)
fetch.side_effect = RuntimeError
update_manifests(ids=(self.addon.pk,))
retry.assert_called()
# Not using assert_called_with b/c eta is a datetime.
eq_(retry.call_args[1]['args'], ([self.addon.pk],))
eq_(retry.call_args[1]['kwargs'], {'check_hash': True,
'retries': {self.addon.pk: 1}})
self.assertCloseToNow(retry.call_args[1]['eta'], later)
eq_(retry.call_args[1]['max_retries'], 4)
开发者ID:fwenzel,项目名称:zamboni,代码行数:11,代码来源:test_tasks.py
示例4: test_manifest_fetch_fail
def test_manifest_fetch_fail(self, retry, fetch):
later = datetime.datetime.now() + datetime.timedelta(seconds=3600)
fetch.side_effect = RuntimeError
update_manifests(ids=(self.addon.pk,))
retry.assert_called()
# Not using assert_called_with b/c eta is a datetime.
eq_(retry.call_args[1]["args"], ([self.addon.pk],))
eq_(retry.call_args[1]["kwargs"], {"check_hash": True, "retries": {self.addon.pk: 1}})
self.assertCloseToNow(retry.call_args[1]["eta"], later)
eq_(retry.call_args[1]["max_retries"], 5)
eq_(len(mail.outbox), 0)
开发者ID:Jobava,项目名称:zamboni,代码行数:11,代码来源:test_tasks.py
示例5: test_manifest_fetch_3rd_attempt
def test_manifest_fetch_3rd_attempt(self, retry, fetch):
fetch.side_effect = RuntimeError
update_manifests(ids=(self.addon.pk,), retries={self.addon.pk: 2})
# We already tried twice before, this is the 3rd attempt,
# We should notify the developer that something is wrong.
eq_(len(mail.outbox), 1)
msg = mail.outbox[0]
ok_(msg.subject.startswith('Issue with your app'))
expected = u'Failed to get manifest from %s' % self.addon.manifest_url
ok_(expected in msg.body)
ok_(settings.MKT_SUPPORT_EMAIL in msg.body)
# We should have scheduled a retry.
assert retry.called
# We shouldn't have put the app in the rereview queue yet.
assert not RereviewQueue.objects.filter(addon=self.addon).exists()
开发者ID:AALEKH,项目名称:zamboni,代码行数:17,代码来源:test_tasks.py
示例6: addons_section
def addons_section(request, addon_id, addon, section, editable=False, webapp=False):
basic = AppFormBasic if webapp else addon_forms.AddonFormBasic
models = {
"basic": basic,
"media": AppFormMedia,
"details": AppFormDetails,
"support": AppFormSupport,
"technical": AppFormTechnical,
"admin": forms.AdminSettingsForm,
}
is_dev = acl.check_addon_ownership(request, addon, dev=True)
if section not in models:
raise http.Http404()
version = addon.current_version or addon.latest_version
tags, previews, restricted_tags = [], [], []
cat_form = appfeatures = appfeatures_form = None
# Permissions checks.
# Only app owners can edit any of the details of their apps.
# Users with 'Apps:Configure' can edit the admin settings.
if (section != "admin" and not is_dev) or (
section == "admin"
and not acl.action_allowed(request, "Apps", "Configure")
and not acl.action_allowed(request, "Apps", "ViewConfiguration")
):
raise PermissionDenied
if section == "basic":
cat_form = CategoryForm(request.POST or None, product=addon, request=request)
elif section == "media":
previews = PreviewFormSet(request.POST or None, prefix="files", queryset=addon.get_previews())
elif section == "technical":
# Only show the list of features if app isn't packaged.
if waffle.switch_is_active("buchets") and not addon.is_packaged and section == "technical":
appfeatures = version.features
formdata = request.POST if request.method == "POST" else None
appfeatures_form = AppFeaturesForm(formdata, instance=appfeatures)
elif section == "admin":
tags = addon.tags.not_blacklisted().values_list("tag_text", flat=True)
restricted_tags = addon.tags.filter(restricted=True)
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == "POST":
if section == "admin" and not acl.action_allowed(request, "Apps", "Configure"):
raise PermissionDenied
form = models[section](request.POST, request.FILES, instance=addon, request=request)
all_forms = [form, previews]
if appfeatures_form:
all_forms.append(appfeatures_form)
if cat_form:
all_forms.append(cat_form)
if all(not f or f.is_valid() for f in all_forms):
if cat_form:
cat_form.save()
addon = form.save(addon)
if appfeatures_form:
appfeatures_form.save()
if "manifest_url" in form.changed_data:
addon.update(app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
editable = False
if section == "media":
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
valid_slug = addon.app_slug
else:
form = models[section](instance=addon, request=request)
else:
form = False
data = {
"addon": addon,
"webapp": webapp,
"version": version,
"form": form,
"editable": editable,
"tags": tags,
"restricted_tags": restricted_tags,
#.........这里部分代码省略.........
开发者ID:rskumar,项目名称:zamboni,代码行数:101,代码来源:views.py
示例7: test_update_manifest
def test_update_manifest(self, retry, fetch):
fetch.return_value = '{}'
update_manifests(ids=(self.addon.pk,))
assert not retry.called
开发者ID:AALEKH,项目名称:zamboni,代码行数:4,代码来源:test_tasks.py
示例8: _run
def _run(self, _get_content_hash, **kw):
# Will run the task and will act depending upon how you've set hash.
_get_content_hash.return_value = self._hash
update_manifests(ids=(self.addon.pk,), **kw)
开发者ID:AALEKH,项目名称:zamboni,代码行数:4,代码来源:test_tasks.py
示例9: addons_section
def addons_section(request, addon_id, addon, section, editable=False,
webapp=False):
basic = AppFormBasic if webapp else addon_forms.AddonFormBasic
models = {'basic': basic,
'media': AppFormMedia,
'details': AppFormDetails,
'support': AppFormSupport,
'technical': AppFormTechnical,
'admin': forms.AdminSettingsForm}
if section not in models:
raise http.Http404()
tags = image_assets = previews = restricted_tags = []
cat_form = None
if section == 'basic':
tags = addon.tags.not_blacklisted().values_list('tag_text', flat=True)
cat_form = CategoryForm(request.POST or None, product=addon,
request=request)
restricted_tags = addon.tags.filter(restricted=True)
elif section == 'media':
image_assets = ImageAssetFormSet(
request.POST or None, prefix='images', app=addon)
previews = PreviewFormSet(
request.POST or None, prefix='files',
queryset=addon.get_previews())
elif (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure') and
not acl.action_allowed(request, 'Apps', 'ViewConfiguration')):
raise PermissionDenied
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == 'POST':
if (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure')):
raise PermissionDenied
form = models[section](request.POST, request.FILES,
instance=addon, request=request)
if (form.is_valid()
and (not previews or previews.is_valid())
and (not image_assets or image_assets.is_valid())):
addon = form.save(addon)
if 'manifest_url' in form.changed_data:
addon.update(
app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
if image_assets:
image_assets.save()
editable = False
if section == 'media':
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
valid_slug = addon.app_slug
if cat_form:
if cat_form.is_valid():
cat_form.save()
addon.save()
else:
editable = True
else:
form = models[section](instance=addon, request=request)
else:
form = False
data = {'addon': addon,
'webapp': webapp,
'form': form,
'editable': editable,
'tags': tags,
'restricted_tags': restricted_tags,
'image_sizes': APP_IMAGE_SIZES,
'cat_form': cat_form,
'preview_form': previews,
'image_asset_form': image_assets,
'valid_slug': valid_slug, }
return jingo.render(request,
'developers/apps/edit/%s.html' % section, data)
开发者ID:bearstech,项目名称:zamboni,代码行数:95,代码来源:views.py
示例10: addons_section
def addons_section(request, addon_id, addon, section, editable=False):
models = {
"basic": AppFormBasic,
"media": AppFormMedia,
"details": AppFormDetails,
"support": AppFormSupport,
"technical": AppFormTechnical,
"admin": forms.AdminSettingsForm,
}
is_dev = acl.check_addon_ownership(request, addon, dev=True)
if section not in models:
raise http.Http404()
version = addon.current_version or addon.latest_version
tags, previews, restricted_tags = [], [], []
cat_form = appfeatures = appfeatures_form = version_form = None
formdata = request.POST if request.method == "POST" else None
# Permissions checks.
# Only app owners can edit any of the details of their apps.
# Users with 'Apps:Configure' can edit the admin settings.
if (section != "admin" and not is_dev) or (
section == "admin"
and not acl.action_allowed(request, "Apps", "Configure")
and not acl.action_allowed(request, "Apps", "ViewConfiguration")
):
raise PermissionDenied
if section == "basic":
cat_form = CategoryForm(formdata, product=addon, request=request)
# Only show/use the release notes form for hosted apps, packaged apps
# can do that from the version edit page.
if not addon.is_packaged:
version_form = AppVersionForm(formdata, instance=version)
elif section == "media":
previews = PreviewFormSet(request.POST or None, prefix="files", queryset=addon.get_previews())
elif section == "technical":
# Only show/use the features form for hosted apps, packaged apps
# can do that from the version edit page.
if not addon.is_packaged:
appfeatures = version.features
appfeatures_form = AppFeaturesForm(formdata, instance=appfeatures)
elif section == "admin":
tags = addon.tags.not_blacklisted().values_list("tag_text", flat=True)
restricted_tags = addon.tags.filter(restricted=True)
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == "POST":
if section == "admin" and not acl.action_allowed(request, "Apps", "Configure"):
raise PermissionDenied
form = models[section](formdata, request.FILES, instance=addon, version=version, request=request)
all_forms = [form, previews]
for additional_form in (appfeatures_form, cat_form, version_form):
if additional_form:
all_forms.append(additional_form)
if all(not f or f.is_valid() for f in all_forms):
if cat_form:
cat_form.save()
addon = form.save(addon)
if appfeatures_form:
appfeatures_form.save()
if version_form:
# We are re-using version_form without displaying all its
# fields, so we need to override the boolean fields,
# otherwise they'd be considered empty and therefore False.
version_form.cleaned_data["publish_immediately"] = version_form.fields[
"publish_immediately"
].initial
version_form.save()
if "manifest_url" in form.changed_data:
addon.update(app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
editable = False
if section == "media":
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
valid_slug = addon.app_slug
#.........这里部分代码省略.........
开发者ID:ngokevin,项目名称:zamboni,代码行数:101,代码来源:views.py
示例11: addons_section
def addons_section(request, addon_id, addon, section, editable=False,
webapp=False):
basic = AppFormBasic if webapp else addon_forms.AddonFormBasic
models = {'basic': basic,
'media': AppFormMedia,
'details': AppFormDetails,
'support': AppFormSupport,
'technical': AppFormTechnical,
'admin': forms.AdminSettingsForm}
is_dev = acl.check_addon_ownership(request, addon, dev=True)
if section not in models:
raise http.Http404()
version = addon.current_version or addon.latest_version
tags, previews, restricted_tags = [], [], []
cat_form = appfeatures = appfeatures_form = None
# Permissions checks.
# Only app owners can edit any of the details of their apps.
# Users with 'Apps:Configure' can edit the admin settings.
if (section != 'admin' and not is_dev) or (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure') and
not acl.action_allowed(request, 'Apps', 'ViewConfiguration')):
raise PermissionDenied
if section == 'basic':
cat_form = CategoryForm(request.POST or None, product=addon,
request=request)
elif section == 'media':
previews = PreviewFormSet(
request.POST or None, prefix='files',
queryset=addon.get_previews())
elif section == 'technical':
# Only show the list of features if app isn't packaged.
if (waffle.switch_is_active('buchets') and not addon.is_packaged and
section == 'technical'):
appfeatures = version.features
formdata = request.POST if request.method == 'POST' else None
appfeatures_form = AppFeaturesForm(formdata, instance=appfeatures)
elif section == 'admin':
tags = addon.tags.not_blacklisted().values_list('tag_text', flat=True)
restricted_tags = addon.tags.filter(restricted=True)
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == 'POST':
if (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure')):
raise PermissionDenied
form = models[section](request.POST, request.FILES,
instance=addon, request=request)
all_forms = [form, previews]
if appfeatures_form:
all_forms.append(appfeatures_form)
if cat_form:
all_forms.append(cat_form)
if all(not f or f.is_valid() for f in all_forms):
if cat_form:
cat_form.save()
addon = form.save(addon)
if appfeatures_form:
appfeatures_form.save()
if 'manifest_url' in form.changed_data:
addon.update(
app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
editable = False
if section == 'media':
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
valid_slug = addon.app_slug
else:
form = models[section](instance=addon, request=request)
else:
form = False
data = {'addon': addon,
'webapp': webapp,
'version': version,
'form': form,
#.........这里部分代码省略.........
开发者ID:sylvesterwillis,项目名称:zamboni,代码行数:101,代码来源:views.py
示例12: addons_section
def addons_section(request, addon_id, addon, section, editable=False):
basic = AppFormBasic
models = {'basic': basic,
'media': AppFormMedia,
'details': AppFormDetails,
'support': AppFormSupport,
'technical': AppFormTechnical,
'admin': forms.AdminSettingsForm}
is_dev = acl.check_addon_ownership(request, addon, dev=True)
if section not in models:
raise http.Http404()
version = addon.current_version or addon.latest_version
tags, previews, restricted_tags = [], [], []
cat_form = appfeatures = appfeatures_form = version_form = None
formdata = request.POST if request.method == 'POST' else None
# Permissions checks.
# Only app owners can edit any of the details of their apps.
# Users with 'Apps:Configure' can edit the admin settings.
if (section != 'admin' and not is_dev) or (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure') and
not acl.action_allowed(request, 'Apps', 'ViewConfiguration')):
raise PermissionDenied
if section == 'basic':
cat_form = CategoryForm(formdata, product=addon, request=request)
# Only show/use the release notes form for hosted apps, packaged apps
# can do that from the version edit page.
if not addon.is_packaged:
version_form = AppVersionForm(formdata, instance=version)
elif section == 'media':
previews = PreviewFormSet(
request.POST or None, prefix='files',
queryset=addon.get_previews())
elif section == 'technical':
# Only show/use the features form for hosted apps, packaged apps
# can do that from the version edit page.
if not addon.is_packaged:
appfeatures = version.features
appfeatures_form = AppFeaturesForm(formdata, instance=appfeatures)
elif section == 'admin':
tags = addon.tags.not_blacklisted().values_list('tag_text', flat=True)
restricted_tags = addon.tags.filter(restricted=True)
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == 'POST':
if (section == 'admin' and
not acl.action_allowed(request, 'Apps', 'Configure')):
raise PermissionDenied
form = models[section](formdata, request.FILES,
instance=addon, request=request)
all_forms = [form, previews]
for additional_form in (appfeatures_form, cat_form, version_form):
if additional_form:
all_forms.append(additional_form)
if all(not f or f.is_valid() for f in all_forms):
if cat_form:
cat_form.save()
addon = form.save(addon)
if appfeatures_form:
appfeatures_form.save()
if version_form:
# We are re-using version_form without displaying all its
# fields, so we need to override the boolean fields,
# otherwise they'd be considered empty and therefore False.
version_form.cleaned_data['publish_immediately'] = (
version_form.fields['publish_immediately'].initial)
version_form.save()
if 'manifest_url' in form.changed_data:
addon.update(
app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
editable = False
if section == 'media':
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
#.........这里部分代码省略.........
开发者ID:patilkr,项目名称:zamboni,代码行数:101,代码来源:views.py
示例13: test_update_manifest
def test_update_manifest(self, retry, fetch):
def f(self):
return '{}'
fetch.side_effect = f
update_manifests(ids=(self.addon.pk,))
assert not retry.called
开发者ID:dimonov,项目名称:zamboni,代码行数:6,代码来源:test_tasks.py
示例14: addons_section
def addons_section(request, addon_id, addon, section, editable=False, webapp=False):
basic = AppFormBasic if webapp else addon_forms.AddonFormBasic
models = {
"basic": basic,
"media": AppFormMedia,
"details": AppFormDetails,
"support": AppFormSupport,
"technical": addon_forms.AddonFormTechnical,
"admin": forms.AdminSettingsForm,
}
if section not in models:
raise http.Http404()
tags = previews = restricted_tags = []
cat_form = device_type_form = region_form = None
if section == "basic":
tags = addon.tags.not_blacklisted().values_list("tag_text", flat=True)
cat_form = CategoryForm(request.POST or None, product=addon, request=request)
restricted_tags = addon.tags.filter(restricted=True)
device_type_form = DeviceTypeForm(request.POST or None, addon=addon)
elif section == "media":
previews = PreviewFormSet(request.POST or None, prefix="files", queryset=addon.get_previews())
elif section == "details" and settings.REGION_STORES:
region_form = RegionForm(request.POST or None, product=addon)
elif (
section == "admin"
and not acl.action_allowed(request, "Apps", "Configure")
and not acl.action_allowed(request, "Apps", "ViewConfiguration")
):
return http.HttpResponseForbidden()
# Get the slug before the form alters it to the form data.
valid_slug = addon.app_slug
if editable:
if request.method == "POST":
if section == "admin" and not acl.action_allowed(request, "Apps", "Configure"):
return http.HttpResponseForbidden()
form = models[section](request.POST, request.FILES, instance=addon, request=request)
if (
form.is_valid()
and (not previews or previews.is_valid())
and (not region_form or region_form.is_valid())
):
if region_form:
region_form.save()
addon = form.save(addon)
if "manifest_url" in form.changed_data:
addon.update(app_domain=addon.domain_from_url(addon.manifest_url))
update_manifests([addon.pk])
if previews:
for preview in previews.forms:
preview.save(addon)
editable = False
if section == "media":
amo.log(amo.LOG.CHANGE_ICON, addon)
else:
amo.log(amo.LOG.EDIT_PROPERTIES, addon)
valid_slug = addon.app_slug
if cat_form:
if cat_form.is_valid():
cat_form.save()
addon.save()
else:
editable = True
if device_type_form:
if device_type_form.is_valid():
device_type_form.save(addon)
addon.save()
else:
editable = True
else:
form = models[section](instance=addon, request=request)
else:
form = False
data = {
"addon": addon,
"webapp": webapp,
"form": form,
"editable": editable,
"tags": tags,
"restricted_tags": restricted_tags,
"cat_form": cat_form,
"preview_form": previews,
"valid_slug": valid_slug,
"device_type_form": device_type_form,
"region_form": region_form,
#.........这里部分代码省略.........
开发者ID:dbialer,项目名称:zamboni,代码行数:101,代码来源:views.py
示例15: test_error
def test_error(self, _get_content_hash):
_get_content_hash.side_effect = Exception()
update_manifests(ids=(self.addon.pk,))
eq_(ActivityLog.objects.for_addons(self.addon).count(), 0)
开发者ID:beenishkhan,项目名称:zamboni,代码行数:4,代码来源:test_tasks.py
示例16: _run
def _run(self, _get_content_hash):
# Will run the task and will act depending upon how you've set hash.
_get_content_hash.side_effect = self._write
update_manifests(ids=(self.addon.pk,))
开发者ID:beenishkhan,项目名称:zamboni,代码行数:4,代码来源:test_tasks.py
注:本文中的mkt.webapps.tasks.update_manifests函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论