當前位置: 首頁>>代碼示例>>Python>>正文


Python Template.ga_version方法代碼示例

本文整理匯總了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())
開發者ID:rananda,項目名稱:cfme_tests,代碼行數:33,代碼來源:views.py

示例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())
開發者ID:lcouzens,項目名稱:cfme_tests,代碼行數:38,代碼來源:views.py


注:本文中的appliances.models.Template.ga_version方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。