本文整理汇总了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")
示例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))
示例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"))
示例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))
示例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)
示例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)
示例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))
示例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"),
)
示例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))
示例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"))
示例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)
示例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)