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


Python Context.from_object方法代码示例

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


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

示例1: profile

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def profile(user_id):
    # current_user is the login-in user, check whether the current user want to view his own profile.
    current_user = Context.from_object(__get_api(API_USER, {"token": session.get("token")}))
    searched_user = Context.from_object(__get_api(API_USER, params={"user_id": user_id}))
    if "id" in current_user and "id" in searched_user and current_user.id == searched_user.id:
        return redirect("/user/profile")
    return render("/user/profile.html")
开发者ID:RangeForce,项目名称:open-hackathon,代码行数:9,代码来源:route_user.py

示例2: temp_settings

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def temp_settings(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session["token"]}
    reg = Context.from_object(__get_api(API_HACAKTHON_REGISTRATION, headers))

    if reg.get("registration") is not None:
        if reg.get("experiment") is not None:
            return redirect(url_for("workspace", hackathon_name=hackathon_name))
        elif reg.registration.status == 1 or (reg.registration.status == 3 and reg.hackathon.basic_info.auto_approve):
            templates = Context.from_object(__get_api(API_HACKATHON_TEMPLATE, headers))
            return render("/site/settings.html", hackathon_name=hackathon_name, templates=templates)
        else:
            return redirect(url_for("hackathon", hackathon_name=hackathon_name))
    else:
        return redirect(url_for("hackathon", hackathon_name=hackathon_name))
开发者ID:xunxunzgq,项目名称:open-hackathon,代码行数:16,代码来源:__init__.py

示例3: hackathon

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def hackathon(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    data = __get_api(API_HACKATHON, headers)
    data = Context.from_object(data)
    reg = Context.from_object(__get_api(API_HACAKTHON_REGISTRATION, headers))
    if data.get('error') is not None:
        return render("/404.html")
    else:
        return render("/site/hackathon.html",
                      hackathon_name=hackathon_name,
                      hackathon=data.get("hackathon", data),
                      user=data.get("user"),
                      registration=data.get("registration"),
                      experiment=reg.get("experiment"))
开发者ID:vitan,项目名称:open-hackathon,代码行数:16,代码来源:__init__.py

示例4: temp_settings

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def temp_settings(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    reg = Context.from_object(
        __get_api(API_HACKATHON, {"hackathon_name": hackathon_name, "token": session.get("token")}))

    if reg.get('registration') is not None:
        if reg.get('experiment') is not None:
            return redirect(url_for('workspace', hackathon_name=hackathon_name))
        elif reg.registration.status == 1 or reg.registration.status == 3:
            templates = Context.from_object(__get_api(API_HACKATHON_TEMPLATE, headers))
            return render("/site/settings.html", hackathon_name=hackathon_name, templates=templates)
        else:
            return redirect(url_for('hackathon', hackathon_name=hackathon_name))
    else:
        return redirect(url_for('hackathon', hackathon_name=hackathon_name))
开发者ID:ifhuang,项目名称:open-hackathon,代码行数:17,代码来源:__init__.py

示例5: create_join_team

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def create_join_team(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session["token"]}
    member = Context.from_object(__get_api(API_TEAM_MEMBER_LIST, headers))
    if member.get('team') is None:
        return redirect(url_for('user_team_hackathon', hackathon_name=hackathon_name))
    else:
        return render("/site/team.html", hackathon_name=hackathon_name)
开发者ID:mshubian,项目名称:open-hackathon,代码行数:9,代码来源:__init__.py

示例6: create_join_team

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def create_join_team(hackathon_name, tid):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    team = Context.from_object(__get_api(API_TEAM, headers, params={"id": tid}))
    if team.get('error') is not None:
        return redirect('404')
    else:
        role = team.is_admin and 4 or 0
        role += team.is_leader and 2 or 0
        role += team.is_member and 1 or 0
        return render("/site/team.html", hackathon_name=hackathon_name, team=team, role=role)
开发者ID:ifhuang,项目名称:open-hackathon,代码行数:12,代码来源:__init__.py

示例7: workspace

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def workspace(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session["token"]}
    reg = Context.from_object(__get_api(API_HACAKTHON_REGISTRATION, headers))

    if reg.get('registration') is not None:
        if reg.registration.status == 1 or (reg.registration.status == 3 and reg.hackathon.basic_info.auto_approve):
            return render("/site/workspace.html", hackathon_name=hackathon_name,
                          workspace=True,
                          hackathon=reg.get("hackathon"),
                          experiment=reg.get('experiment', {id: 0}))
        else:
            return redirect(url_for('hackathon', hackathon_name=hackathon_name))
    else:
        return redirect(url_for('hackathon', hackathon_name=hackathon_name))
开发者ID:mshubian,项目名称:open-hackathon,代码行数:16,代码来源:__init__.py

示例8: hackathon

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def hackathon(hackathon_name):
    data = __get_api(API_HACKATHON, {"hackathon_name": hackathon_name, "token": session.get("token")})
    data = Context.from_object(data)

    if data.get("error") is not None or data.get("hackathon", data).status != 1:
        return render("/404.html")
    else:
        return render(
            "/site/hackathon.html",
            hackathon_name=hackathon_name,
            hackathon=data.get("hackathon", data),
            user=data.get("user"),
            registration=data.get("registration"),
            experiment=data.get("experiment"),
        )
开发者ID:xunxunzgq,项目名称:open-hackathon,代码行数:17,代码来源:__init__.py

示例9: workspace

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def workspace(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    reg = Context.from_object(__get_api(API_HACKATHON_REGISTRATION, headers))

    if reg.get('registration') is not None:
        if reg.registration.status == 1 or reg.registration.status == 3:
            return render("/site/workspace.html", hackathon_name=hackathon_name,
                          workspace=True,
                          asset=reg.get("asset"),
                          hackathon=reg.get("hackathon"),
                          experiment=reg.get('experiment', {id: 0}))
        else:
            return redirect(url_for('hackathon', hackathon_name=hackathon_name))
    else:
        return redirect(url_for('hackathon', hackathon_name=hackathon_name))
开发者ID:lclchen,项目名称:open-hackathon,代码行数:17,代码来源:__init__.py

示例10: hackathon

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def hackathon(hackathon_name):
    if current_user.is_authenticated():
        data = __get_api(API_HACAKTHON_REGISTRATION, {"hackathon_name": hackathon_name, "token": session["token"]})
    else:
        data = __get_api(API_HACKATHON, {"hackathon_name": hackathon_name})

    data = Context.from_object(data)

    if data.get('error') is not None or data.get('hackathon', data).status != 1:
        return render("/404.html")
    else:
        return render("/site/hackathon.html",
                      hackathon_name=hackathon_name,
                      hackathon=data.get("hackathon", data),
                      user=data.get("user"),
                      registration=data.get("registration"),
                      experiment=data.get("experiment"))
开发者ID:mshubian,项目名称:open-hackathon,代码行数:19,代码来源:__init__.py

示例11: create_join_team

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def create_join_team(hackathon_name, tid):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    team = Context.from_object(__get_api(API_TEAM, headers, params={"id": tid}))
    return render_team_page(hackathon_name, team)
开发者ID:rapidhere,项目名称:open-hackathon,代码行数:6,代码来源:__init__.py

示例12: my_team

# 需要导入模块: from client import Context [as 别名]
# 或者: from client.Context import from_object [as 别名]
def my_team(hackathon_name):
    headers = {"hackathon_name": hackathon_name, "token": session.get("token")}
    team = Context.from_object(__get_api(API_MY_TEAM, headers))
    return render_team_page(hackathon_name, team)
开发者ID:rapidhere,项目名称:open-hackathon,代码行数:6,代码来源:__init__.py


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