示例#1
0
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
0
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")
示例#3
0
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))
示例#4
0
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"))
示例#5
0
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_HACKATHON_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"),
                      team=data.get("team"),
                      experiment=reg.get("experiment"))
示例#6
0
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))
示例#7
0
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))
示例#8
0
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)
示例#9
0
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)
示例#10
0
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)
示例#11
0
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))
示例#12
0
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))
示例#13
0
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))
示例#14
0
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"),
        )
示例#15
0
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))
示例#16
0
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"))
示例#17
0
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))
示例#18
0
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"))
示例#19
0
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)
示例#20
0
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)
示例#21
0
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)
示例#22
0
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)