本文整理汇总了Python中versions.models.Version类的典型用法代码示例。如果您正苦于以下问题:Python Version类的具体用法?Python Version怎么用?Python Version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Version类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: status
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,代码行数:33,代码来源:views.py
示例17: 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'Published,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:chusiang,项目名称:zamboni,代码行数:16,代码来源:test_helpers.py
示例18: test_app_versions
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,代码行数:7,代码来源:tests.py
示例19: test_mobile_all_with_mixed_desktop_creates_platform_files
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,代码行数:8,代码来源:tests.py
示例20: test_desktop_all_with_mixed_mobile_creates_platform_files
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,代码行数:8,代码来源:tests.py
注:本文中的versions.models.Version类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论