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


Python ModuleSetting.add_for_module方法代码示例

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


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

示例1: integration_add

# 需要导入模块: from maker.core.models import ModuleSetting [as 别名]
# 或者: from maker.core.models.ModuleSetting import add_for_module [as 别名]
def integration_add(request, resource_id, response_format="html"):
    "Integration add new resource page"

    user = request.user.get_profile()

    conf = ModuleSetting.get("nuvius_profile", user=user)
    try:
        profile = conf[0].loads()
    except IndexError:
        profile = None

    resource = None
    data = None
    if profile:
        connector = Connector(request, profile_id=profile["id"])
        resource = DataBlock(connector.get_app(resource_id))
        if request.POST and "add" in request.POST:
            resource = IntegrationResource(profile["id"], resource_id, resource.application.name.raw, "9rw")
            conf = ModuleSetting.add_for_module("integration_resource", "", "maker.identities", user=user)
            conf.dumps(resource).save()
            return HttpResponseRedirect(reverse("identities_integration_index"))
        else:
            data = connector.get(
                "/service/contact-book/contact/data.json/id" + profile["id"] + "/app" + unicode(resource_id),
                no_cache=True,
            )
            data = DataBlock(data)
            if data.result_name == "success":
                pass
            elif data.result_name == "redirect":
                next = request.build_absolute_uri(reverse("identities_integration_add", args=[resource_id]))
                data = connector.get(
                    "/service/contact-book/contact/data.json/id" + profile["id"] + "/app" + unicode(resource_id),
                    parameters={"next": next},
                    no_cache=True,
                )
            data = DataBlock(data)

    context = _get_default_context(request)
    context.update({"resource_id": resource_id, "resource": resource, "data": data})

    return render_to_response(
        "identities/integration_add", context, context_instance=RequestContext(request), response_format=response_format
    )
开发者ID:alejo8591,项目名称:maker,代码行数:46,代码来源:views.py


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