Ejemplo n.º 1
0
def get_potential_mates(user):
    # Yep, this is O(n^2). It also doesn't cache the result. Scaling
    # is something that happens to other people...

    scores = dict()
    current_mates = db.get_all_mates(user)
    for mate in current_mates:
        for person in db.get_all_mates(mate):
            if person not in current_mates and person != user:
                if person not in scores:
                    scores[person] = 0
                scores[person] += 1

    for course in db.get_all_courses(user):
        for person in db.get_course_members(course):
            if person not in current_mates and person != user:
                if person not in scores:
                    scores[person] = 0
                scores[person] += 1

    return scores
Ejemplo n.º 2
0
def render(request):
    course = request["course"].value
    d = {"course": safety.make_safe(course)}
    d["members"] = userlist.render(db.get_course_members(course))

    return tempy.render("courses.template", d)