예제 #1
0
def friends():
    friends = data.execute("SELECT r_id1, name1, r_id2, name AS name2 FROM (SELECT r_id1, name AS name1, r_id2 FROM (SELECT * FROM Friends UNION (SELECT r_id2 AS r_id1, r_id1 AS r_id2 FROM Friends)) AS a INNER JOIN Russer ON r_id1 = r_id) AS b INNER JOIN Russer ON r_id2 = r_id ORDER BY name1")
    friends = itertools.groupby(friends, key=get('name1'))
    friends = [(x[0], list(x[1])) for x in friends]
    friends = [({'name1':name, 'r_id1':l[0]['r_id1']}, l) for name, l in friends]

    user_friends = data.execute("SELECT username, Users.name as users_name, r_id, Russer.name as russer_name FROM Friends_of_us INNER JOIN Users USING (username) INNER JOIN Russer Using (r_id) ORDER BY Russer.name")
    user_friends = itertools.groupby(user_friends, key=get('russer_name'))
    user_friends = [(x[0], list(x[1])) for x in user_friends]
    user_friends = [({'russer_name':name, 'r_id':l[0]['r_id']}, l) for name, l in user_friends]

    return render_template("rusmanager/friends.html", friends=friends, user_friends=user_friends)
예제 #2
0
def groups_overview():
    groups = data.execute('SELECT * FROM Group_users INNER JOIN Users USING (username) ORDER BY groupname, username')
    groups = itertools.groupby(groups, key=get('groupname'))
    groups = [(x[0], list(x[1])) for x in groups]

    all_groups = data.execute("SELECT groupname FROM Groups ORDER BY groupname")
    all_groups = [group['groupname'] for group in all_groups]

    result = []
    for group in all_groups:
        if len(groups) > 0 and groups[0][0] == group:
            result.append(groups.pop(0))
        else:
            result.append((group, []))
    groups = result

    return render_template("admin/group_overview.html", groups=groups)
예제 #3
0
def groups_overview():
    groups = data.execute(
        'SELECT * FROM Group_users INNER JOIN Users USING (username) ORDER BY groupname, username'
    )
    groups = itertools.groupby(groups, key=get('groupname'))
    groups = [(x[0], list(x[1])) for x in groups]

    all_groups = data.execute(
        "SELECT groupname FROM Groups ORDER BY groupname")
    all_groups = [group['groupname'] for group in all_groups]

    result = []
    for group in all_groups:
        if len(groups) > 0 and groups[0][0] == group:
            result.append(groups.pop(0))
        else:
            result.append((group, []))
    groups = result

    return render_template("admin/group_overview.html", groups=groups)
예제 #4
0
def rustour(t_id):
    tour = data.execute("SELECT * FROM Tours WHERE t_id = ?", t_id)[0]
    russer = data.execute("SELECT * FROM Russer WHERE rustour = ? ORDER BY name ASC", t_id)
    tutors = data.execute("SELECT * FROM tours_tutors WHERE t_id = ? ORDER BY username ASC", t_id)

    dutyteams = data.execute("SELECT Russer.r_id, Russer.name, Dutyteams.name as dutyteam FROM Russer FULL OUTER JOIN Dutyteams ON Russer.dutyteam = Dutyteams.d_id WHERE Russer.rustour = ? and Russer.dutyteam IS NOT NULL ORDER BY Dutyteams.d_id ASC", t_id)
    dutyteams = itertools.groupby(dutyteams, key=get("dutyteam"))
    dutyteams = [(x[0], list(x[1])) for x in dutyteams]

    all_teams = data.execute("SELECT name FROM Dutyteams WHERE t_id = ? ORDER BY d_id ASC", t_id)
    all_teams = [x['name'] for x in all_teams]

    result = []
    for team in all_teams:
        if len(dutyteams) > 0 and dutyteams[0][0] == team:
            result.append(dutyteams.pop(0))
        else:
            result.append((team, []))
    dutyteams = result

    unassigned = data.execute("SELECT r_id, name FROM Russer WHERE rustour = ? AND dutyteam IS NULL ORDER BY name DESC", t_id)

    return render_template("rustours/rustour.html", tour=tour, russer=russer, tutors=tutors, dutyteams=dutyteams, unassigned=unassigned)
예제 #5
0
def rustour(t_id):
    tour = data.execute("SELECT * FROM Tours WHERE t_id = ?", t_id)[0]
    russer = data.execute(
        "SELECT * FROM Russer WHERE rustour = ? ORDER BY name ASC", t_id)
    tutors = data.execute(
        "SELECT * FROM tours_tutors WHERE t_id = ? ORDER BY username ASC",
        t_id)

    dutyteams = data.execute(
        "SELECT Russer.r_id, Russer.name, Dutyteams.name as dutyteam FROM Russer FULL OUTER JOIN Dutyteams ON Russer.dutyteam = Dutyteams.d_id WHERE Russer.rustour = ? and Russer.dutyteam IS NOT NULL ORDER BY Dutyteams.d_id ASC",
        t_id)
    dutyteams = itertools.groupby(dutyteams, key=get("dutyteam"))
    dutyteams = [(x[0], list(x[1])) for x in dutyteams]

    all_teams = data.execute(
        "SELECT name FROM Dutyteams WHERE t_id = ? ORDER BY d_id ASC", t_id)
    all_teams = [x['name'] for x in all_teams]

    result = []
    for team in all_teams:
        if len(dutyteams) > 0 and dutyteams[0][0] == team:
            result.append(dutyteams.pop(0))
        else:
            result.append((team, []))
    dutyteams = result

    unassigned = data.execute(
        "SELECT r_id, name FROM Russer WHERE rustour = ? AND dutyteam IS NULL ORDER BY name DESC",
        t_id)

    return render_template("rustours/rustour.html",
                           tour=tour,
                           russer=russer,
                           tutors=tutors,
                           dutyteams=dutyteams,
                           unassigned=unassigned)
예제 #6
0
def overview():
    tours = data.execute("SELECT * FROM Tours ORDER BY year DESC, tour_name ASC")
    tours = itertools.groupby(tours, key=get("year"))
    return render_template("rustours/overview.html", tours=tours)
예제 #7
0
def overview():
    teams = data.execute("SELECT * FROM Mentorteams LEFT JOIN Mentors USING (m_id) LEFT JOIN Users USING (username) ORDER BY year DESC, mentor_names ASC")
    teams = itertools.groupby(teams, key=get("year"))
    teams = [(x[0], [(y[0], list(y[1])) for y in itertools.groupby(x[1], key=get("m_id"))]) for x in teams]
    return render_template("mentorteams/overview.html", teams=teams)
예제 #8
0
def overview():
    tours = data.execute(
        "SELECT * FROM Tours ORDER BY year DESC, tour_name ASC")
    tours = itertools.groupby(tours, key=get("year"))
    return render_template("rustours/overview.html", tours=tours)