当前位置: 首页>>代码示例>>Python>>正文


Python models.Version类代码示例

本文整理汇总了Python中versions.models.Version的典型用法代码示例。如果您正苦于以下问题:Python Version类的具体用法?Python Version怎么用?Python Version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_status_beta

    def test_status_beta(self, parse_addon):
        parse_addon.return_value = {'version': u'0.1beta'}

        qs = File.objects.filter(version=self.current)
        Version.from_upload(self.upload, self.addon, [self.platform])
        eq_(sorted([q.status for q in qs.all()]),
            [amo.STATUS_UNREVIEWED, amo.STATUS_PUBLIC])
开发者ID:Sancus,项目名称:zamboni,代码行数:7,代码来源:tests.py

示例2: 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:Dreadchild,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例3: transformer

    def transformer(addons):
        if not addons:
            return

        addon_dict = dict((a.id, a) for a in addons)
        personas = [a for a in addons if a.type_id == amo.ADDON_PERSONA]
        addons = [a for a in addons if a.type_id != amo.ADDON_PERSONA]

        # TODO(jbalogh): It would be awesome to get the versions in one
        # (or a few) queries, but we'll accept the overhead here to roll up
        # some version queries.
        versions = filter(None, (a.current_version for a in addons))
        Version.transformer(versions)

        # Attach listed authors.
        q = (UserProfile.objects.no_cache()
             .filter(addons__in=addons, addonuser__listed=True)
             .extra(select={'addon_id': 'addons_users.addon_id'})
             .order_by('addon_id', 'addonuser__position'))
        for addon_id, users in itertools.groupby(q, key=lambda u: u.addon_id):
            addon_dict[addon_id].listed_authors = list(users)

        for persona in Persona.objects.no_cache().filter(addon__in=personas):
            addon_dict[persona.addon_id].persona = persona
            addon_dict[persona.addon_id].listed_authors = []

        # Personas need categories for the JSON dump.
        Category.transformer(personas)
开发者ID:chowse,项目名称:zamboni,代码行数:28,代码来源:models.py

示例4: manifest_updated

    def manifest_updated(self, manifest, upload):
        """The manifest has updated, create a version and file."""

        # This does most of the heavy work.
        Version.from_upload(upload, self, [])
        # Triggering this ensures that the current_version gets updated.
        self.update_version()
        amo.log(amo.LOG.MANIFEST_UPDATED, self)
开发者ID:cestep01,项目名称:zamboni,代码行数:8,代码来源:models.py

示例5: test_version_status

def test_version_status():
    addon = Addon()
    version = Version()
    version.all_files = [File(status=amo.STATUS_PUBLIC), File(status=amo.STATUS_UNREVIEWED)]
    eq_(u"Fully Reviewed,Awaiting Review", helpers.version_status(addon, version))

    version.all_files = [File(status=amo.STATUS_UNREVIEWED)]
    eq_(u"Awaiting Review", helpers.version_status(addon, version))
开发者ID:aniketkudale,项目名称:olympia,代码行数:8,代码来源:test_helpers.py

示例6: create_version

 def create_version(self, license=None):
     data = self.cleaned_data
     v = Version(addon=self.addon, license=license, version=data["version"], releasenotes=data["release_notes"])
     v.save()
     amo.log(amo.LOG.ADD_VERSION, v.addon, v)
     self._save_apps(v)
     self._save_file(v)
     return v
开发者ID:rubenvereecken,项目名称:olympia,代码行数:8,代码来源:forms.py

示例7: version_list

def version_list(request, addon_id):
    addon = get_object_or_404(Addon.objects.valid(), pk=addon_id)
    qs = (addon.versions.filter(files__status__in=amo.VALID_STATUSES)
          .distinct().order_by('-created'))
    versions = amo.utils.paginate(request, qs, PER_PAGE)
    versions.object_list = list(versions.object_list)
    Version.transformer(versions.object_list)
    return jingo.render(request, 'versions/version_list.html',
                        {'addon': addon, 'versions': versions})
开发者ID:fligtar,项目名称:zamboni,代码行数:9,代码来源:views.py

示例8: create_version

 def create_version(self, license=None):
     data = self.cleaned_data
     v = Version(addon=self.addon, license=license,
                 version=data['version'],
                 releasenotes=data['release_notes'])
     v.save()
     self._save_apps(v)
     self._save_file(v)
     return v
开发者ID:ozten,项目名称:zamboni,代码行数:9,代码来源:forms.py

示例9: version_list

def version_list(request, addon, template, beta=False):
    status_list = (amo.STATUS_BETA,) if beta else amo.VALID_STATUSES
    qs = (addon.versions.filter(files__status__in=status_list)
          .distinct().order_by('-created'))
    versions = amo.utils.paginate(request, qs, PER_PAGE)
    versions.object_list = list(versions.object_list)
    Version.transformer(versions.object_list)
    return render(request, template, {'addon': addon, 'beta': beta,
                                      'versions': versions})
开发者ID:ddurst,项目名称:olympia,代码行数:9,代码来源:views.py

示例10: test_version_status

def test_version_status():
    addon = Addon()
    version = Version()
    version.all_files = [File(status=amo.STATUS_PUBLIC),
                         File(status=amo.STATUS_DELETED)]
    eq_(u'Fully Reviewed,Deleted', helpers.version_status(addon, version))

    version.all_files = [File(status=amo.STATUS_UNREVIEWED)]
    eq_(u'Awaiting Preliminary Review', helpers.version_status(addon, version))
开发者ID:aditbiswas1,项目名称:olympia,代码行数:9,代码来源:test_helpers.py

示例11: _extra_version_and_file

    def _extra_version_and_file(self, status):
        version = Version.objects.get(id=81551)

        version_two = Version(addon=self.addon, license=version.license, version="1.2.3")
        version_two.save()

        file_two = File(status=status, version=version_two)
        file_two.save()
        return version_two, file_two
开发者ID:rhelmer,项目名称:zamboni,代码行数:9,代码来源:test_views_versions.py

示例12: create_file

    def create_file(self, **kwargs):
        addon = Addon()
        addon.save()
        ver = Version(version='0.1')
        ver.addon = addon
        ver.save()

        f = File(**kwargs)
        f.version = ver
        f.save()

        return f
开发者ID:ujdhesa,项目名称:olympia,代码行数:12,代码来源:test_models.py

示例13: from_upload

 def from_upload(cls, upload, platforms):
     from files.utils import parse_addon
     data = parse_addon(upload.path)
     fields = cls._meta.get_all_field_names()
     addon = Addon(**dict((k, v) for k, v in data.items() if k in fields))
     addon.status = amo.STATUS_NULL
     addon.default_locale = to_language(translation.get_language())
     addon.save()
     Version.from_upload(upload, addon, platforms)
     amo.log(amo.LOG.CREATE_ADDON, addon)
     log.debug('New addon %r from %r' % (addon, upload))
     return addon
开发者ID:zuzelvp,项目名称:zamboni,代码行数:12,代码来源:models.py

示例14: manifest_updated

    def manifest_updated(self, manifest):
        """The manifest has updated, create a version and file."""
        with open(manifest) as fh:
            chunks = fh.read()

        # We'll only create a file upload when we detect that the manifest
        # has changed, otherwise we'll be creating an awful lot of these.
        upload = FileUpload.from_post(chunks, manifest, len(chunks))
        # This does most of the heavy work.
        Version.from_upload(upload, self,
                            [Platform.objects.get(id=amo.PLATFORM_ALL.id)])
        # Triggering this ensures that the current_version gets updated.
        self.update_version()
        amo.log(amo.LOG.MANIFEST_UPDATED, self)
开发者ID:gkoberger,项目名称:zamboni,代码行数:14,代码来源:models.py

示例15: test_version_status

def test_version_status():
    addon = Addon()
    version = Version()
    version.all_files = [File(status=amo.STATUS_PUBLIC), File(status=amo.STATUS_DELETED)]
    eq_(u"Fully Reviewed,Deleted", helpers.version_status(addon, version))

    version.all_files = [File(status=amo.STATUS_UNREVIEWED)]
    eq_(u"Awaiting Preliminary Review", helpers.version_status(addon, version))

    with patch.object(settings, "MARKETPLACE", True):
        version.all_files = [File(status=amo.STATUS_PENDING)]
        eq_(u"Pending approval", helpers.version_status(addon, version))

        version.deleted = True
        eq_(u"Deleted", helpers.version_status(addon, version))
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:15,代码来源:test_helpers.py


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