本文整理汇总了Python中mkt.versions.models.Version类的典型用法代码示例。如果您正苦于以下问题:Python Version类的具体用法?Python Version怎么用?Python Version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Version类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_large_version_int
def test_large_version_int(self):
# This version will fail to be written to the version_int
# table because the resulting int is bigger than mysql bigint.
version = Version(addon=Addon.objects.get(pk=337141))
version.version = '9223372036854775807'
version.save()
eq_(version.version_int, None)
示例2: test_developer_name_from_upload
def test_developer_name_from_upload(self, parse_addon):
parse_addon.return_value = {"version": "42.0", "developer_name": u"Mýself"}
addon = Webapp.objects.get(pk=337141)
# Note: we need a valid FileUpload instance, but in the end we are not
# using its contents since we are mocking parse_addon().
path = os.path.join(settings.ROOT, "mkt", "developers", "tests", "addons", "mozball.webapp")
upload = self.get_upload(abspath=path)
version = Version.from_upload(upload, addon)
eq_(version.version, "42.0")
eq_(version.developer_name, u"Mýself")
示例3: test_developer_name_from_upload
def test_developer_name_from_upload(self, parse_webapp):
parse_webapp.return_value = {
'version': '42.0',
'developer_name': u'Mýself'
}
webapp = Webapp.objects.get(pk=337141)
# Note: we need a valid FileUpload instance, but in the end we are not
# using its contents since we are mocking parse_webapp().
path = os.path.join(settings.ROOT, 'mkt', 'developers', 'tests',
'webapps', 'mozball.webapp')
upload = self.get_upload(abspath=path)
version = Version.from_upload(upload, webapp)
eq_(version.version, '42.0')
eq_(version.developer_name, u'Mýself')
示例4: test_developer_name_from_upload
def test_developer_name_from_upload(self, parse_addon):
parse_addon.return_value = {
'version': '42.0',
'developer_name': u'Mýself'
}
addon = Addon.objects.get(pk=337141)
# Note: we need a valid FileUpload instance, but in the end we are not
# using its contents since we are mocking parse_addon().
path = os.path.join(settings.ROOT, 'mkt', 'developers', 'tests',
'addons', 'mozball.webapp')
upload = self.get_upload(abspath=path)
platform = Platform.objects.get(pk=amo.PLATFORM_ALL.id)
version = Version.from_upload(upload, addon, [platform])
eq_(version.version, '42.0')
eq_(version.developer_name, u'Mýself')
示例5: test_long_developer_name_from_upload
def test_long_developer_name_from_upload(self, parse_addon):
truncated_developer_name = u'ý' * 255
long_developer_name = truncated_developer_name + u'àààà'
parse_addon.return_value = {
'version': '42.1',
'developer_name': long_developer_name
}
addon = Webapp.objects.get(pk=337141)
# Note: we need a valid FileUpload instance, but in the end we are not
# using its contents since we are mocking parse_addon().
path = os.path.join(settings.ROOT, 'mkt', 'developers', 'tests',
'addons', 'mozball.webapp')
upload = self.get_upload(abspath=path)
version = Version.from_upload(upload, addon)
eq_(version.version, '42.1')
eq_(version.developer_name, truncated_developer_name)
示例6: status
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
#.........这里部分代码省略.........
示例7: status
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 or 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, [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)
# 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,
'upload_form': upload_form, 'publish_form': publish_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
#.........这里部分代码省略.........
示例8: _get_version
def _get_version(self, status):
v = Version()
v.all_files = [mock.Mock()]
v.all_files[0].status = status
return v
示例9: create_version
def create_version(self, addon, upload):
"""Create new Version instance from a FileUpload instance"""
self.info('Creating new Version...')
version = Version.from_upload(upload, addon)
self.info('Created new Version %s.' % version)
return version