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


Python Version.from_upload方法代码示例

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


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

示例1: test_status_beta

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
    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,代码行数:9,代码来源:tests.py

示例2: manifest_updated

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
    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,代码行数:10,代码来源:models.py

示例3: from_upload

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 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,代码行数:14,代码来源:models.py

示例4: manifest_updated

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
    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,代码行数:16,代码来源:models.py

示例5: test_app_versions

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_app_versions(self):
     version = Version.from_upload(self.upload, self.addon,
                                   [self.platform])
     assert amo.FIREFOX in version.compatible_apps
     app = version.compatible_apps[amo.FIREFOX]
     eq_(app.min.version, '3.0')
     eq_(app.max.version, '3.6.*')
开发者ID:Sancus,项目名称:zamboni,代码行数:9,代码来源:tests.py

示例6: status

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
def status(request, addon_id, addon, webapp=False):
    form = forms.AppAppealForm(request.POST, product=addon)
    upload_form = NewWebappForm(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])
            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}

    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)
开发者ID:Sancus,项目名称:zamboni,代码行数:35,代码来源:views.py

示例7: test_desktop_all_with_mixed_mobile_creates_platform_files

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_desktop_all_with_mixed_mobile_creates_platform_files(self):
     all_desktop = Platform.objects.get(id=amo.PLATFORM_ALL.id)
     android = Platform.objects.get(id=amo.PLATFORM_ANDROID.id)
     version = Version.from_upload(self.upload, self.addon, [all_desktop,
                                                             android])
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform.id].shortname for f in files),
         ['android', 'linux', 'mac', 'windows'])
开发者ID:Sancus,项目名称:zamboni,代码行数:10,代码来源:tests.py

示例8: test_mobile_all_with_mixed_desktop_creates_platform_files

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_mobile_all_with_mixed_desktop_creates_platform_files(self):
     all_mobile = Platform.objects.get(id=amo.PLATFORM_ALL_MOBILE.id)
     linux = Platform.objects.get(id=amo.PLATFORM_LINUX.id)
     version = Version.from_upload(self.upload, self.addon, [linux,
                                                             all_mobile])
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform.id].shortname for f in files),
         ['android', 'linux', 'maemo'])
开发者ID:Sancus,项目名称:zamboni,代码行数:10,代码来源:tests.py

示例9: test_mobile_all_desktop_all_creates_all

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_mobile_all_desktop_all_creates_all(self):
     all_desktop = Platform.objects.get(id=amo.PLATFORM_ALL.id)
     all_mobile = Platform.objects.get(id=amo.PLATFORM_ALL_MOBILE.id)
     version = Version.from_upload(self.upload, self.addon, [all_desktop,
                                                             all_mobile])
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform.id].shortname for f in files),
         ['all'])
开发者ID:Sancus,项目名称:zamboni,代码行数:10,代码来源:tests.py

示例10: version_add

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
def version_add(request, addon_id, addon):
    form = forms.NewVersionForm(request.POST, addon=addon)
    if form.is_valid():
        v = Version.from_upload(form.cleaned_data['upload'], addon,
                                form.cleaned_data['platforms'])
        url = reverse('devhub.versions.edit', args=[addon.slug, str(v.id)])
        return dict(url=url)
    else:
        return json_view.error(form.errors)
开发者ID:exezaid,项目名称:zamboni,代码行数:11,代码来源:views.py

示例11: test_desktop_all_android_creates_all

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_desktop_all_android_creates_all(self):
     version = Version.from_upload(
         self.upload,
         self.addon,
         [amo.PLATFORM_ALL.id, amo.PLATFORM_ANDROID.id]
     )
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform].shortname for f in files),
         ['all', 'android'])
开发者ID:chetanmelkani,项目名称:olympia,代码行数:11,代码来源:tests.py

示例12: test_mobile_all_with_mixed_desktop_creates_platform_files

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_mobile_all_with_mixed_desktop_creates_platform_files(self):
     version = Version.from_upload(
         self.upload,
         self.addon,
         [amo.PLATFORM_LINUX.id, amo.PLATFORM_ALL_MOBILE.id]
     )
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform].shortname for f in files),
         ['android', 'linux', 'maemo'])
开发者ID:waytai,项目名称:olympia,代码行数:11,代码来源:tests.py

示例13: test_mobile_all_desktop_all_creates_all

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_mobile_all_desktop_all_creates_all(self):
     version = Version.from_upload(
         self.upload,
         self.addon,
         [amo.PLATFORM_ALL.id, amo.PLATFORM_ALL_MOBILE.id]
     )
     files = version.all_files
     eq_(sorted(amo.PLATFORMS[f.platform].shortname for f in files),
         ['all'])
开发者ID:waytai,项目名称:olympia,代码行数:11,代码来源:tests.py

示例14: test_status_beta

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
 def test_status_beta(self):
     # Create a version and switch the add-on status to public.
     Version.from_upload(self.upload, self.addon, [self.platform])
     File.objects.all().update(status=amo.STATUS_PUBLIC)
     self.addon.update(status=amo.STATUS_PUBLIC)
     # Create an under review version.
     upload = self.get_upload('extension-0.2.xpi')
     Version.from_upload(upload, self.addon, [self.platform])
     # Create a beta version.
     upload = self.get_upload('extension-0.2b1.xpi')
     version = Version.from_upload(upload, self.addon, [self.platform],
                                   is_beta=True)
     # Check that it doesn't modify the public status and that the
     # created file is in the beta status.
     eq_(File.objects.filter(version=self.current)[0].status,
         amo.STATUS_PUBLIC)
     eq_(self.addon.status, amo.STATUS_PUBLIC)
     eq_(File.objects.filter(version=version)[0].status, amo.STATUS_BETA)
开发者ID:waytai,项目名称:olympia,代码行数:20,代码来源:tests.py

示例15: version_add

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import from_upload [as 别名]
def version_add(request, addon_id, addon):
    form = forms.NewVersionForm(request.POST, addon=addon)
    if form.is_valid():
        pl = (list(form.cleaned_data['desktop_platforms']) +
              list(form.cleaned_data['mobile_platforms']))
        v = Version.from_upload(form.cleaned_data['upload'], addon, pl)
        log.info('Version created: %s for: %s' %
                 (v.pk, form.cleaned_data['upload']))
        url = reverse('devhub.versions.edit', args=[addon.slug, str(v.id)])
        return dict(url=url)
    else:
        return json_view.error(form.errors)
开发者ID:frankk00,项目名称:zamboni,代码行数:14,代码来源:views.py


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