當前位置: 首頁>>代碼示例>>Python>>正文


Python client.Context類代碼示例

本文整理匯總了Python中client.Context的典型用法代碼示例。如果您正苦於以下問題:Python Context類的具體用法?Python Context怎麽用?Python Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Context類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: profile

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,代碼行數:7,代碼來源:route_user.py

示例2: temp_settings

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,代碼行數:14,代碼來源:__init__.py

示例3: hackathon

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,代碼行數:14,代碼來源:__init__.py

示例4: temp_settings

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,代碼行數:15,代碼來源:__init__.py

示例5: create_join_team

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,代碼行數:7,代碼來源:__init__.py

示例6: create_join_team

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,代碼行數:10,代碼來源:__init__.py

示例7: workspace

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,代碼行數:14,代碼來源:__init__.py

示例8: hackathon

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,代碼行數:15,代碼來源:__init__.py

示例9: workspace

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,代碼行數:15,代碼來源:__init__.py

示例10: hackathon

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,代碼行數:17,代碼來源:__init__.py

示例11: create_join_team

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,代碼行數:4,代碼來源:__init__.py

示例12: my_team

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,代碼行數:4,代碼來源:__init__.py


注:本文中的client.Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。