Ejemplo n.º 1
0
def get_courses_pane(user):
    if not privacy.permitted(user, "courses"):
        return ""

    result = ""
    for course in db.get_all_courses(user):
        result += '<a href="?course=' + course + '"><p style="text-align: center">' + course + "</p></a>"
    return result
Ejemplo n.º 2
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