本文整理汇总了Python中mkt.submit.forms.NewWebappVersionForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python NewWebappVersionForm.is_valid方法的具体用法?Python NewWebappVersionForm.is_valid怎么用?Python NewWebappVersionForm.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mkt.submit.forms.NewWebappVersionForm
的用法示例。
在下文中一共展示了NewWebappVersionForm.is_valid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon, webapp=False):
form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True,
addon=addon)
if request.method == 'POST':
if 'resubmit-app' in request.POST and form.is_valid():
form.save()
messages.success(request, _('App successfully resubmitted.'))
return redirect(addon.get_dev_url('versions'))
elif 'upload-version' in request.POST and upload_form.is_valid():
ver = Version.from_upload(upload_form.cleaned_data['upload'],
addon, [amo.PLATFORM_ALL])
messages.success(request, _('New version successfully added.'))
log.info('[Webapp:%s] New version created id=%s from upload: %s'
% (addon, ver.pk, upload_form.cleaned_data['upload']))
return redirect(addon.get_dev_url('versions.edit', args=[ver.pk]))
ctx = {'addon': addon, 'webapp': webapp, 'form': form,
'upload_form': upload_form}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values('id', 'version')
version_strings = dict((v['id'], v) for v in versions)
version_strings['num'] = len(versions)
ctx['version_strings'] = json.dumps(version_strings)
if addon.status == amo.STATUS_REJECTED:
try:
entry = (AppLog.objects
.filter(addon=addon,
activity_log__action=amo.LOG.REJECT_VERSION.id)
.order_by('-created'))[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx['rejection'] = entry and entry.activity_log
return jingo.render(request, 'developers/apps/status.html', ctx)
示例2: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon):
appeal_form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True, addon=addon, request=request)
publish_form = forms.PublishForm(request.POST if "publish-app" in request.POST else None, addon=addon)
if request.method == "POST":
if "resubmit-app" in request.POST and appeal_form.is_valid():
if not addon.is_rated():
# Cannot resubmit without content ratings.
return http.HttpResponseForbidden("This app must obtain content ratings before being " "resubmitted.")
appeal_form.save()
create_comm_note(
addon, addon.latest_version, request.user, appeal_form.data["notes"], note_type=comm.RESUBMISSION
)
if addon.vip_app:
handle_vip(addon, addon.latest_version, request.user)
messages.success(request, _("App successfully resubmitted."))
return redirect(addon.get_dev_url("versions"))
elif "upload-version" in request.POST and upload_form.is_valid():
upload = upload_form.cleaned_data["upload"]
ver = Version.from_upload(upload, addon)
# Update addon status now that the new version was saved.
addon.update_status()
res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)
# Escalate the version if it uses prerelease permissions.
escalate_prerelease_permissions(addon, validation_result, ver)
# Set all detected features as True and save them.
keys = ["has_%s" % feature.lower() for feature in validation_result["feature_profile"]]
data = defaultdict.fromkeys(keys, True)
# Set "Smartphone-Sized Displays" if it's a mobile-only app.
qhd_devices = (
set((amo.DEVICE_GAIA,)),
set((amo.DEVICE_MOBILE,)),
set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE)),
)
mobile_only = addon.latest_version and addon.latest_version.features.has_qhd
if set(addon.device_types) in qhd_devices or mobile_only:
data["has_qhd"] = True
# Update feature profile for this version.
ver.features.update(**data)
messages.success(request, _("New version successfully added."))
log.info("[Webapp:%s] New version created id=%s from upload: %s" % (addon, ver.pk, upload))
if addon.vip_app:
handle_vip(addon, ver, request.user)
return redirect(addon.get_dev_url("versions.edit", args=[ver.pk]))
elif "publish-app" in request.POST and publish_form.is_valid():
publish_form.save()
return redirect(addon.get_dev_url("versions"))
ctx = {
"addon": addon,
"appeal_form": appeal_form,
"is_tarako": addon.tags.filter(tag_text=QUEUE_TARAKO).exists(),
"tarako_review": addon.additionalreview_set.latest_for_queue(QUEUE_TARAKO),
"publish_form": publish_form,
"QUEUE_TARAKO": QUEUE_TARAKO,
"upload_form": upload_form,
}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values("id", "version")
version_strings = dict((v["id"], v) for v in versions)
version_strings["num"] = len(versions)
ctx["version_strings"] = json.dumps(version_strings)
if addon.status == amo.STATUS_REJECTED:
try:
entry = (
AppLog.objects.filter(addon=addon, activity_log__action=amo.LOG.REJECT_VERSION.id).order_by("-created")
)[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx["rejection"] = entry and entry.activity_log
if waffle.switch_is_active("preload-apps"):
test_plan = PreloadTestPlan.objects.filter(addon=addon, status=amo.STATUS_PUBLIC)
if test_plan.exists():
test_plan = test_plan[0]
if test_plan.last_submission < settings.PREINSTALL_TEST_PLAN_LATEST:
ctx["outdated_test_plan"] = True
ctx["next_step_suffix"] = "submit"
else:
ctx["next_step_suffix"] = "home"
ctx["test_plan"] = test_plan
#.........这里部分代码省略.........
示例3: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon, webapp=False):
form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True,
addon=addon, request=request)
if request.method == 'POST':
if 'resubmit-app' in request.POST and form.is_valid():
form.save()
perms = ('reviewer', 'senior_reviewer', 'staff')
create_comm_thread(action='resubmit', addon=addon,
comments=form.data['notes'], profile=request.amo_user,
version=addon.current_version, perms=perms)
messages.success(request, _('App successfully resubmitted.'))
return redirect(addon.get_dev_url('versions'))
elif 'upload-version' in request.POST and upload_form.is_valid():
mobile_only = (addon.latest_version and
addon.latest_version.features.has_qhd)
ver = Version.from_upload(upload_form.cleaned_data['upload'],
addon, [amo.PLATFORM_ALL])
# Update addon status now that the new version was saved.
addon.update_status()
res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)
# Set all detected features as True and save them.
keys = ['has_%s' % feature.lower()
for feature in validation_result['feature_profile']]
data = defaultdict.fromkeys(keys, True)
# Set "Smartphone-Sized Displays" if it's a mobile-only app.
qhd_devices = (set((amo.DEVICE_GAIA,)),
set((amo.DEVICE_MOBILE,)),
set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE,)))
if set(addon.device_types) in qhd_devices or mobile_only:
data['has_qhd'] = True
# Update feature profile for this version.
ver.features.update(**data)
messages.success(request, _('New version successfully added.'))
log.info('[Webapp:%s] New version created id=%s from upload: %s'
% (addon, ver.pk, upload_form.cleaned_data['upload']))
return redirect(addon.get_dev_url('versions.edit', args=[ver.pk]))
ctx = {'addon': addon, 'webapp': webapp, 'form': form,
'upload_form': upload_form}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values('id', 'version')
version_strings = dict((v['id'], v) for v in versions)
version_strings['num'] = len(versions)
ctx['version_strings'] = json.dumps(version_strings)
if addon.status == amo.STATUS_REJECTED:
try:
entry = (AppLog.objects
.filter(addon=addon,
activity_log__action=amo.LOG.REJECT_VERSION.id)
.order_by('-created'))[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx['rejection'] = entry and entry.activity_log
if waffle.switch_is_active('preload-apps'):
test_plan = PreloadTestPlan.objects.filter(
addon=addon, status=amo.STATUS_PUBLIC)
if test_plan.exists():
test_plan = test_plan[0]
if (test_plan.last_submission <
settings.PREINSTALL_TEST_PLAN_LATEST):
ctx['outdated_test_plan'] = True
ctx['next_step_suffix'] = 'submit'
else:
ctx['next_step_suffix'] = 'home'
ctx['test_plan'] = test_plan
return jingo.render(request, 'developers/apps/status.html', ctx)
示例4: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon):
appeal_form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True,
addon=addon, request=request)
publish_form = forms.PublishForm(
request.POST if 'publish-app' in request.POST else None, addon=addon)
if request.method == 'POST':
if 'resubmit-app' in request.POST and appeal_form.is_valid():
if not addon.is_rated():
# Cannot resubmit without content ratings.
return http.HttpResponseForbidden(
'This app must obtain content ratings before being '
'resubmitted.')
appeal_form.save()
create_comm_note(addon, addon.latest_version,
request.user, appeal_form.data['notes'],
note_type=comm.RESUBMISSION)
if addon.vip_app:
handle_vip(addon, addon.latest_version, request.user)
messages.success(request, _('App successfully resubmitted.'))
return redirect(addon.get_dev_url('versions'))
elif 'upload-version' in request.POST and upload_form.is_valid():
upload = upload_form.cleaned_data['upload']
ver = Version.from_upload(upload, addon)
# Update addon status now that the new version was saved.
addon.update_status()
res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)
# Escalate the version if it uses prerelease permissions.
escalate_prerelease_permissions(addon, validation_result, ver)
# Set all detected features as True and save them.
keys = ['has_%s' % feature.lower()
for feature in validation_result['feature_profile']]
data = defaultdict.fromkeys(keys, True)
# Set "Smartphone-Sized Displays" if it's a mobile-only app.
qhd_devices = (set((mkt.DEVICE_GAIA,)),
set((mkt.DEVICE_MOBILE,)),
set((mkt.DEVICE_GAIA, mkt.DEVICE_MOBILE,)))
mobile_only = (addon.latest_version and
addon.latest_version.features.has_qhd)
if set(addon.device_types) in qhd_devices or mobile_only:
data['has_qhd'] = True
# Update feature profile for this version.
ver.features.update(**data)
messages.success(request, _('New version successfully added.'))
log.info('[Webapp:%s] New version created id=%s from upload: %s'
% (addon, ver.pk, upload))
if addon.vip_app:
handle_vip(addon, ver, request.user)
return redirect(addon.get_dev_url('versions.edit', args=[ver.pk]))
elif 'publish-app' in request.POST and publish_form.is_valid():
publish_form.save()
return redirect(addon.get_dev_url('versions'))
ctx = {
'addon': addon,
'appeal_form': appeal_form,
'is_tarako': addon.tags.filter(tag_text=QUEUE_TARAKO).exists(),
'tarako_review': addon.additionalreview_set
.latest_for_queue(QUEUE_TARAKO),
'publish_form': publish_form,
'QUEUE_TARAKO': QUEUE_TARAKO,
'upload_form': upload_form,
}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values('id', 'version')
version_strings = dict((v['id'], v) for v in versions)
version_strings['num'] = len(versions)
ctx['version_strings'] = json.dumps(version_strings)
if addon.status == mkt.STATUS_REJECTED:
try:
entry = (AppLog.objects
.filter(addon=addon,
activity_log__action=mkt.LOG.REJECT_VERSION.id)
.order_by('-created'))[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx['rejection'] = entry and entry.activity_log
if waffle.switch_is_active('preload-apps'):
test_plan = PreloadTestPlan.objects.filter(
addon=addon, status=mkt.STATUS_PUBLIC)
#.........这里部分代码省略.........
示例5: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon, webapp=False):
form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True,
addon=addon, request=request)
if request.method == 'POST':
if 'resubmit-app' in request.POST and form.is_valid():
form.save()
messages.success(request, _('App successfully resubmitted.'))
return redirect(addon.get_dev_url('versions'))
elif 'upload-version' in request.POST and upload_form.is_valid():
mobile_only = (addon.latest_version and
addon.latest_version.features.has_qhd)
ver = Version.from_upload(upload_form.cleaned_data['upload'],
addon, [amo.PLATFORM_ALL])
res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)
# Set all detected features as True and save them.
keys = ['has_%s' % feature.lower()
for feature in validation_result['feature_profile']]
data = defaultdict.fromkeys(keys, True)
# Set "Smartphone-Sized Displays" if it's a mobile-only app.
qhd_devices = (set((amo.DEVICE_GAIA,)),
set((amo.DEVICE_MOBILE,)),
set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE,)))
if set(addon.device_types) in qhd_devices or mobile_only:
data['has_qhd'] = True
# Update feature profile for this version.
ver.features.update(**data)
messages.success(request, _('New version successfully added.'))
log.info('[Webapp:%s] New version created id=%s from upload: %s'
% (addon, ver.pk, upload_form.cleaned_data['upload']))
return redirect(addon.get_dev_url('versions.edit', args=[ver.pk]))
ctx = {'addon': addon, 'webapp': webapp, 'form': form,
'upload_form': upload_form}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values('id', 'version')
version_strings = dict((v['id'], v) for v in versions)
version_strings['num'] = len(versions)
ctx['version_strings'] = json.dumps(version_strings)
if addon.status == amo.STATUS_REJECTED:
try:
entry = (AppLog.objects
.filter(addon=addon,
activity_log__action=amo.LOG.REJECT_VERSION.id)
.order_by('-created'))[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx['rejection'] = entry and entry.activity_log
return jingo.render(request, 'developers/apps/status.html', ctx)
示例6: status
# 需要导入模块: from mkt.submit.forms import NewWebappVersionForm [as 别名]
# 或者: from mkt.submit.forms.NewWebappVersionForm import is_valid [as 别名]
def status(request, addon_id, addon, webapp=False):
form = forms.AppAppealForm(request.POST, product=addon)
upload_form = NewWebappVersionForm(request.POST or None, is_packaged=True, addon=addon, request=request)
if request.method == "POST":
if "resubmit-app" in request.POST and form.is_valid():
form.save()
perms = ("reviewer", "senior_reviewer", "staff")
create_comm_thread(
action="resubmit",
addon=addon,
comments=form.data["notes"],
profile=request.amo_user,
version=addon.current_version,
perms=perms,
)
messages.success(request, _("App successfully resubmitted."))
return redirect(addon.get_dev_url("versions"))
elif "upload-version" in request.POST and upload_form.is_valid():
mobile_only = addon.latest_version and addon.latest_version.features.has_qhd
ver = Version.from_upload(upload_form.cleaned_data["upload"], addon, [amo.PLATFORM_ALL])
# Update addon status now that the new version was saved.
addon.update_status()
res = run_validator(ver.all_files[0].file_path)
validation_result = json.loads(res)
# Set all detected features as True and save them.
keys = ["has_%s" % feature.lower() for feature in validation_result["feature_profile"]]
data = defaultdict.fromkeys(keys, True)
# Set "Smartphone-Sized Displays" if it's a mobile-only app.
qhd_devices = (
set((amo.DEVICE_GAIA,)),
set((amo.DEVICE_MOBILE,)),
set((amo.DEVICE_GAIA, amo.DEVICE_MOBILE)),
)
if set(addon.device_types) in qhd_devices or mobile_only:
data["has_qhd"] = True
# Update feature profile for this version.
ver.features.update(**data)
messages.success(request, _("New version successfully added."))
log.info(
"[Webapp:%s] New version created id=%s from upload: %s"
% (addon, ver.pk, upload_form.cleaned_data["upload"])
)
return redirect(addon.get_dev_url("versions.edit", args=[ver.pk]))
ctx = {"addon": addon, "webapp": webapp, "form": form, "upload_form": upload_form}
# Used in the delete version modal.
if addon.is_packaged:
versions = addon.versions.values("id", "version")
version_strings = dict((v["id"], v) for v in versions)
version_strings["num"] = len(versions)
ctx["version_strings"] = json.dumps(version_strings)
if addon.status == amo.STATUS_REJECTED:
try:
entry = (
AppLog.objects.filter(addon=addon, activity_log__action=amo.LOG.REJECT_VERSION.id).order_by("-created")
)[0]
except IndexError:
entry = None
# This contains the rejection reason and timestamp.
ctx["rejection"] = entry and entry.activity_log
return jingo.render(request, "developers/apps/status.html", ctx)