本文整理匯總了Python中appliances.models.Template.ga_version方法的典型用法代碼示例。如果您正苦於以下問題:Python Template.ga_version方法的具體用法?Python Template.ga_version怎麽用?Python Template.ga_version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類appliances.models.Template
的用法示例。
在下文中一共展示了Template.ga_version方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: versions_for_group
# 需要導入模塊: from appliances.models import Template [as 別名]
# 或者: from appliances.models.Template import ga_version [as 別名]
def versions_for_group(request):
if not request.user.is_authenticated():
return go_home(request)
group_id = request.POST.get("stream")
latest_version = None
preconfigured = request.POST.get("preconfigured", "false").lower() == "true"
container = request.POST.get("container", "false").lower() == "true"
container_q = ~Q(container=None) if container else Q(container=None)
if group_id == "<None>":
versions = []
group = None
else:
try:
group = Group.objects.get(id=group_id)
except ObjectDoesNotExist:
versions = []
else:
versions = [
(version, Template.ga_version(version))
for version in Template.get_versions(
container_q,
template_group=group, ready=True, usable=True, exists=True,
preconfigured=preconfigured, provider__working=True, provider__disabled=False,
provider__user_groups__in=request.user.groups.all())]
if versions:
if versions[0][1]:
latest_version = '{} (GA)'.format(versions[0][0])
else:
latest_version = versions[0][0]
return render(request, 'appliances/_versions.html', locals())
示例2: versions_for_group
# 需要導入模塊: from appliances.models import Template [as 別名]
# 或者: from appliances.models.Template import ga_version [as 別名]
def versions_for_group(request):
group_id = request.POST.get("stream")
template_type = request.POST.get("template_type")
latest_version = None
preconfigured = request.POST.get("preconfigured", "false").lower() == "true"
if group_id == "<None>":
versions = []
group = None
else:
try:
group = Group.objects.get(id=group_id)
except ObjectDoesNotExist:
versions = []
else:
filters = {
'template_group': group,
'ready': True,
'usable': True,
'exists': True,
'provider__working': True,
'provider__disabled': False,
'provider__user_groups__in': request.user.groups.all(),
'preconfigured': preconfigured,
'template_type': template_type
}
versions = [
(version, Template.ga_version(version))
for version in Template.get_versions(**filters)]
if versions:
if versions[0][1]:
latest_version = '{} (GA)'.format(versions[0][0])
else:
latest_version = versions[0][0]
return render(request, 'appliances/_versions.html', locals())