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


Python Template.get_dates方法代码示例

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


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

示例1: date_for_group_and_version

# 需要导入模块: from appliances.models import Template [as 别名]
# 或者: from appliances.models.Template import get_dates [as 别名]
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,代码行数:35,代码来源:views.py

示例2: providers_for_date_group_and_version

# 需要导入模块: from appliances.models import Template [as 别名]
# 或者: from appliances.models.Template import get_dates [as 别名]
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,代码行数:47,代码来源:views.py

示例3: date_for_group_and_version

# 需要导入模块: from appliances.models import Template [as 别名]
# 或者: from appliances.models.Template import get_dates [as 别名]
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,代码行数:41,代码来源:views.py

示例4: num_shepherd_appliances

# 需要导入模块: from appliances.models import Template [as 别名]
# 或者: from appliances.models.Template import get_dates [as 别名]
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,代码行数:39,代码来源:api.py

示例5: providers_for_date_group_and_version

# 需要导入模块: from appliances.models import Template [as 别名]
# 或者: from appliances.models.Template import get_dates [as 别名]
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,代码行数:77,代码来源:views.py


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