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


Python models.Template类代码示例

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


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

示例1: versions_for_group

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,代码行数:31,代码来源:views.py

示例2: date_for_group_and_version

def date_for_group_and_version(request):
    group_id = request.POST.get("stream")
    latest_date = None
    preconfigured = request.POST.get("preconfigured", "false").lower() == "true"
    if group_id == "<None>":
        dates = []
    else:
        try:
            group = Group.objects.get(id=group_id)
        except ObjectDoesNotExist:
            dates = []
        else:
            version = request.POST.get("version")
            filters = {
                "template_group": group,
                "ready": True,
                "exists": True,
                "usable": True,
                "preconfigured": preconfigured,
                "provider__working": True,
            }
            if version == "latest":
                try:
                    versions = Template.get_versions(**filters)
                    filters["version"] = versions[0]
                except IndexError:
                    pass  # No such thing as version for this template group
            else:
                filters["version"] = version
            dates = Template.get_dates(**filters)
            if dates:
                latest_date = dates[0]
    return render(request, 'appliances/_dates.html', locals())
开发者ID:jaryn,项目名称:cfme_tests,代码行数:33,代码来源:views.py

示例3: providers_for_date_group_and_version

def providers_for_date_group_and_version(request):
    total_provisioning_slots = 0
    total_appliance_slots = 0
    group_id = request.POST.get("stream")
    preconfigured = request.POST.get("preconfigured", "false").lower() == "true"
    if group_id == "<None>":
        providers = []
    else:
        try:
            group = Group.objects.get(id=group_id)
        except ObjectDoesNotExist:
            providers = []
        else:
            version = request.POST.get("version")
            filters = {
                "template_group": group,
                "ready": True,
                "exists": True,
                "usable": True,
                "preconfigured": preconfigured,
            }
            if version == "latest":
                try:
                    versions = Template.get_versions(**filters)
                    filters["version"] = versions[0]
                except IndexError:
                    pass  # No such thing as version for this template group
            else:
                filters["version"] = version
            date = request.POST.get("date")
            if date == "latest":
                try:
                    dates = Template.get_dates(**filters)
                    filters["date"] = dates[0]
                except IndexError:
                    pass  # No such thing as date for this template group
            else:
                filters["date"] = parser.parse(date)
            providers = Template.objects.filter(**filters).values("provider").distinct()
            providers = sorted([p.values()[0] for p in providers])
            providers = [Provider.objects.get(id=provider) for provider in providers]
            for provider in providers:
                total_appliance_slots += provider.remaining_appliance_slots
                total_provisioning_slots += provider.remaining_provisioning_slots
    return render(request, 'appliances/_providers.html', locals())
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:45,代码来源:views.py

示例4: date_for_group_and_version

def date_for_group_and_version(request):
    if not request.user.is_authenticated():
        return go_home(request)
    group_id = request.POST.get("stream")
    latest_date = 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>":
        dates = []
    else:
        try:
            group = Group.objects.get(id=group_id)
        except ObjectDoesNotExist:
            dates = []
        else:
            version = request.POST.get("version")
            filters = {
                "template_group": group,
                "ready": True,
                "exists": True,
                "usable": True,
                "preconfigured": preconfigured,
                "provider__working": True,
                'provider__disabled': False,
                "provider__user_groups__in": request.user.groups.all(),
            }
            if version == "latest":
                try:
                    versions = Template.get_versions(container_q, **filters)
                    filters["version"] = versions[0]
                except IndexError:
                    pass  # No such thing as version for this template group
            else:
                filters["version"] = version
            dates = Template.get_dates(container_q, **filters)
            if dates:
                latest_date = dates[0]
    return render(request, 'appliances/_dates.html', locals())
开发者ID:jkandasa,项目名称:integration_tests,代码行数:39,代码来源:views.py

示例5: num_shepherd_appliances

def num_shepherd_appliances(group, version=None, date=None, provider=None):
    """Provides number of currently available shepherd appliances."""
    group = Group.objects.get(id=group)
    if provider is not None:
        provider = Provider.objects.get(id=provider)
    if version is None:
        if provider is None:
            try:
                version = Template.get_versions(template_group=group)[0]
            except IndexError:
                # No version
                pass
        else:
            try:
                version = Template.get_versions(template_group=group, provider=provider)[0]
            except IndexError:
                # No version
                pass
    if date is None:
        filter_kwargs = {"template_group": group}
        if provider is not None:
            filter_kwargs["provider"] = provider
        if version is not None:
            filter_kwargs["version"] = version
        try:
            date = Template.get_dates(**filter_kwargs)[0]
        except IndexError:
            # No date
            pass
    filter_kwargs = {"template__template_group": group, "ready": True, "appliance_pool": None}
    if version is not None:
        filter_kwargs["template__version"] = version
    if date is not None:
        filter_kwargs["template__date"] = date
    if provider is not None:
        filter_kwargs["template__provider"] = provider
    return len(Appliance.objects.filter(**filter_kwargs))
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:37,代码来源:api.py

示例6: versions_for_group

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,代码行数:36,代码来源:views.py

示例7: versions_for_group

def versions_for_group(request):
    group_id = request.POST.get("stream")
    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:
            versions = Template.get_versions(
                template_group=group, ready=True, usable=True, exists=True,
                preconfigured=preconfigured, provider__working=True, provider__disabled=False)
            if versions:
                latest_version = versions[0]

    return render(request, 'appliances/_versions.html', locals())
开发者ID:jaryn,项目名称:cfme_tests,代码行数:20,代码来源:views.py

示例8: providers_for_date_group_and_version

def providers_for_date_group_and_version(request):
    if not request.user.is_authenticated():
        return go_home(request)
    total_provisioning_slots = 0
    total_appliance_slots = 0
    total_shepherd_slots = 0
    shepherd_appliances = {}
    group_id = request.POST.get("stream")
    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 container:
        appliance_container_q = ~Q(template__container=None)
    else:
        appliance_container_q = Q(template__container=None)
    if group_id == "<None>":
        providers = []
    else:
        try:
            group = Group.objects.get(id=group_id)
        except ObjectDoesNotExist:
            providers = []
        else:
            version = request.POST.get("version")
            filters = {
                "template_group": group,
                "ready": True,
                "exists": True,
                "usable": True,
                "preconfigured": preconfigured,
                "provider__working": True,
                "provider__user_groups__in": request.user.groups.all(),
            }
            if version == "latest":
                try:
                    versions = Template.get_versions(container_q, **filters)
                    filters["version"] = versions[0]
                except IndexError:
                    pass  # No such thing as version for this template group
            else:
                filters["version"] = version
            date = request.POST.get("date")
            if date == "latest":
                try:
                    dates = Template.get_dates(container_q, **filters)
                    filters["date"] = dates[0]
                except IndexError:
                    pass  # No such thing as date for this template group
            else:
                filters["date"] = parser.parse(date)
            providers = Template.objects.filter(
                container_q, **filters).values("provider").distinct()
            providers = sorted([p.values()[0] for p in providers])
            providers = [Provider.objects.get(id=provider) for provider in providers]
            for provider in providers:
                appl_filter = dict(
                    appliance_pool=None, ready=True, template__provider=provider,
                    template__preconfigured=filters["preconfigured"],
                    template__template_group=filters["template_group"])
                if "date" in filters:
                    appl_filter["template__date"] = filters["date"]

                if "version" in filters:
                    appl_filter["template__version"] = filters["version"]
                shepherd_appliances[provider.id] = len(
                    Appliance.objects.filter(appliance_container_q, **appl_filter))
                total_shepherd_slots += shepherd_appliances[provider.id]
                total_appliance_slots += provider.remaining_appliance_slots
                total_provisioning_slots += provider.remaining_provisioning_slots

            render_providers = {}
            for provider in providers:
                render_providers[provider.id] = {
                    "shepherd_count": shepherd_appliances[provider.id], "object": provider}
    return render(request, 'appliances/_providers.html', locals())
开发者ID:rananda,项目名称:cfme_tests,代码行数:75,代码来源:views.py

示例9: available_cfme_versions

def available_cfme_versions(preconfigured=True):
    """Lists all versions that are available"""
    return Template.get_versions(preconfigured=preconfigured)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:3,代码来源:api.py


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