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


Python CommCareBuildConfig.fetch方法代码示例

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


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

示例1: commcare_version_report

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def commcare_version_report(request, template="hqadmin/commcare_version.html"):
    apps = get_db().view("app_manager/applications_brief").all()
    menu = CommCareBuildConfig.fetch().menu
    builds = [item.build.to_string() for item in menu]
    by_build = dict([(item.build.to_string(), {"label": item.label, "apps": []}) for item in menu])

    for app in apps:
        app = app["value"]
        app["id"] = app["_id"]
        if app.get("build_spec"):
            build_spec = BuildSpec.wrap(app["build_spec"])
            build = build_spec.to_string()
            if by_build.has_key(build):
                by_build[build]["apps"].append(app)
            else:
                by_build[build] = {"label": build_spec.get_label(), "apps": [app]}
                builds.append(build)

    tables = []
    for build in builds:
        by_build[build]["build"] = build
        tables.append(by_build[build])
    context = get_hqadmin_base_context(request)
    context.update({"tables": tables})
    context["hide_filters"] = True
    return render(request, template, context)
开发者ID:nikhilvarma22,项目名称:commcare-hq,代码行数:28,代码来源:views.py

示例2: get_commcare_builds

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def get_commcare_builds(request_user):
    can_view_superuser_builds = (request_user.is_superuser
                                 or toggles.IS_CONTRACTOR.enabled(request_user.username))
    return [
        i.build
        for i in CommCareBuildConfig.fetch().menu
        if can_view_superuser_builds or not i.superuser_only
    ]
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:10,代码来源:util.py

示例3: get_app_view_context

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def get_app_view_context(request, app):

    is_cloudcare_allowed = has_privilege(request, privileges.CLOUDCARE)
    context = {}

    settings_layout = copy.deepcopy(get_commcare_settings_layout(request.domain)[app.get_doc_type()])
    for section in settings_layout:
        new_settings = []
        for setting in section["settings"]:
            toggle_name = setting.get("toggle")
            if toggle_name and not toggle_enabled(request, toggle_name):
                continue
            privilege_name = setting.get("privilege")
            if privilege_name and not has_privilege(request, privilege_name):
                continue
            disable_if_true = setting.get("disable_if_true")
            if disable_if_true and getattr(app, setting["id"]):
                continue
            new_settings.append(setting)
        section["settings"] = new_settings

    if toggles.CUSTOM_PROPERTIES.enabled(request.domain) and "custom_properties" in app.profile:
        custom_properties_array = map(
            lambda p: {"key": p[0], "value": p[1]}, app.profile.get("custom_properties").items()
        )
        context.update({"custom_properties": custom_properties_array})

    context.update(
        {
            "settings_layout": settings_layout,
            "settings_values": get_settings_values(app),
            "is_cloudcare_allowed": is_cloudcare_allowed,
        }
    )

    build_config = CommCareBuildConfig.fetch()
    options = build_config.get_menu()
    if not request.user.is_superuser:
        options = [option for option in options if not option.superuser_only]
    options_map = defaultdict(lambda: {"values": [], "value_names": []})
    for option in options:
        builds = options_map[option.build.major_release()]
        builds["values"].append(option.build.to_string())
        builds["value_names"].append(option.get_label())
        if "default" not in builds:
            app_ver = MAJOR_RELEASE_TO_VERSION[option.build.major_release()]
            builds["default"] = build_config.get_default(app_ver).to_string()

    (build_spec_setting,) = filter(
        lambda x: x["type"] == "hq" and x["id"] == "build_spec",
        [setting for section in context["settings_layout"] for setting in section["settings"]],
    )
    build_spec_setting["options_map"] = options_map
    build_spec_setting["default_app_version"] = app.application_version

    context.update(
        {
            "bulk_ui_translation_upload": {
                "action": reverse("upload_bulk_ui_translations", args=(app.domain, app.get_id)),
                "download_url": reverse("download_bulk_ui_translations", args=(app.domain, app.get_id)),
                "adjective": _(u"U\u200BI translation"),
                "plural_noun": _(u"U\u200BI translations"),
            },
            "bulk_app_translation_upload": {
                "action": reverse("upload_bulk_app_translations", args=(app.domain, app.get_id)),
                "download_url": reverse("download_bulk_app_translations", args=(app.domain, app.get_id)),
                "adjective": _("app translation"),
                "plural_noun": _("app translations"),
            },
        }
    )
    context.update(
        {
            "bulk_ui_translation_form": get_bulk_upload_form(context, context_key="bulk_ui_translation_upload"),
            "bulk_app_translation_form": get_bulk_upload_form(context, context_key="bulk_app_translation_upload"),
        }
    )
    context["is_app_view"] = True
    try:
        context["fetchLimit"] = int(request.GET.get("limit", DEFAULT_FETCH_LIMIT))
    except ValueError:
        context["fetchLimit"] = DEFAULT_FETCH_LIMIT

    return context
开发者ID:dimagi,项目名称:commcare-hq,代码行数:86,代码来源:apps.py

示例4: get_commcare_versions

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def get_commcare_versions(request_user):
    versions = [i.build.version for i in CommCareBuildConfig.fetch().menu
                if request_user.is_superuser or not i.superuser_only]
    return sorted(versions, key=version_key)
开发者ID:nnestle,项目名称:commcare-hq,代码行数:6,代码来源:util.py

示例5: get_commcare_version

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def get_commcare_version(request, app_id, app_version):
    options = CommCareBuildConfig.fetch().get_menu(app_version)
    return json_response(options)
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:5,代码来源:apps.py

示例6: get_app_view_context

# 需要导入模块: from corehq.apps.builds.models import CommCareBuildConfig [as 别名]
# 或者: from corehq.apps.builds.models.CommCareBuildConfig import fetch [as 别名]
def get_app_view_context(request, app):

    is_cloudcare_allowed = has_privilege(request, privileges.CLOUDCARE)
    context = {}

    settings_layout = copy.deepcopy(
        get_commcare_settings_layout()[app.get_doc_type()])
    for section in settings_layout:
        new_settings = []
        for setting in section['settings']:
            toggle_name = setting.get('toggle')
            if toggle_name and not toggle_enabled(request, toggle_name):
                continue
            privilege_name = setting.get('privilege')
            if privilege_name and not has_privilege(request, privilege_name):
                continue
            new_settings.append(setting)
        section['settings'] = new_settings

    if toggles.CUSTOM_PROPERTIES.enabled(request.domain) and 'custom_properties' in app.profile:
        custom_properties_array = map(lambda p: {'key': p[0], 'value': p[1]},
                                      app.profile.get('custom_properties').items())
        context.update({'custom_properties': custom_properties_array})

    context.update({
        'settings_layout': settings_layout,
        'settings_values': get_settings_values(app),
        'is_cloudcare_allowed': is_cloudcare_allowed,
    })

    build_config = CommCareBuildConfig.fetch()
    options = build_config.get_menu()
    if not request.user.is_superuser:
        options = [option for option in options if not option.superuser_only]
    options_map = defaultdict(lambda: {"values": [], "value_names": []})
    for option in options:
        builds = options_map[option.build.major_release()]
        builds["values"].append(option.build.to_string())
        builds["value_names"].append(option.get_label())
        if "default" not in builds:
            app_ver = MAJOR_RELEASE_TO_VERSION[option.build.major_release()]
            builds["default"] = build_config.get_default(app_ver).to_string()

    (build_spec_setting,) = filter(
        lambda x: x['type'] == 'hq' and x['id'] == 'build_spec',
        [setting for section in context['settings_layout']
            for setting in section['settings']]
    )
    build_spec_setting['options_map'] = options_map
    build_spec_setting['default_app_version'] = app.application_version

    context.update({
        'bulk_ui_translation_upload': {
            'action': reverse('upload_bulk_ui_translations',
                              args=(app.domain, app.get_id)),
            'download_url': reverse('download_bulk_ui_translations',
                                    args=(app.domain, app.get_id)),
            'adjective': _(u"U\u200BI translation"),
            'plural_noun': _(u"U\u200BI translations"),
        },
        'bulk_app_translation_upload': {
            'action': reverse('upload_bulk_app_translations',
                              args=(app.domain, app.get_id)),
            'download_url': reverse('download_bulk_app_translations',
                                    args=(app.domain, app.get_id)),
            'adjective': _("app translation"),
            'plural_noun': _("app translations"),
        },
    })
    context.update({
        'bulk_ui_translation_form': get_bulk_upload_form(
            context,
            context_key="bulk_ui_translation_upload"
        ),
        'bulk_app_translation_form': get_bulk_upload_form(
            context,
            context_key="bulk_app_translation_upload"
        )
    })
    context['is_app_view'] = True
    return context
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:83,代码来源:apps.py


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