• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Version类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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)
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例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")
开发者ID:ujdhesa,项目名称:zamboni,代码行数:10,代码来源:test_models.py


示例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')
开发者ID:shahbaz17,项目名称:zamboni,代码行数:14,代码来源:test_models.py


示例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')
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:15,代码来源:test_models.py


示例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)
开发者ID:MaxMillion,项目名称:zamboni,代码行数:16,代码来源:test_models.py


示例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
#.........这里部分代码省略.........
开发者ID:ngokevin,项目名称:zamboni,代码行数:101,代码来源:views.py


示例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
#.........这里部分代码省略.........
开发者ID:patilkr,项目名称:zamboni,代码行数:101,代码来源:views.py


示例8: _get_version

 def _get_version(self, status):
     v = Version()
     v.all_files = [mock.Mock()]
     v.all_files[0].status = status
     return v
开发者ID:ujdhesa,项目名称:zamboni,代码行数:5,代码来源:test_models.py


示例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
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:6,代码来源:upload_new_marketplace_package.py



注:本文中的mkt.versions.models.Version类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cron.update_weekly_downloads函数代码示例发布时间:2022-05-27
下一篇:
Python utils.to_language函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap