Beispiel #1
0
def drawChoices(wantedGender):
    pool = sorted(db.session.query(Person).filter(and_(Person.gender == wantedGender, Person.hidden == False, Person.facebookId != None)).all(), key=lambda x: x.games)
    L, R = sample(pool[:50], 2) # at first, choices are selected from the least voted persons
    if randint(1, 2) == 1:      # in order to guarantee variety, each choice has a 50% chance
        L = choice(pool)        # of being re-chosen from the entire person pool
    if randint(1, 2) == 1:
        R = choice(pool)

    while L == R:
        R = choice(pool)

    # picL = solveRedirect(SETTINGS['basePic'] % (L.username, 500, 500))
    # picR = solveRedirect(SETTINGS['basePic'] % (R.username, 500, 500))
    # ^the solveRedirect method is EXTREMELY slow
    picL = getProfilePictureLocation(L)
    picR = getProfilePictureLocation(R)

    nuevoL = ' (nuev%s)' % ['a', 'o'][L.gender] if '8' in L.school else None
    nuevoR = ' (nuev%s)' % ['a', 'o'][R.gender] if '8' in R.school else None

    return {
            'L': L,
            'R': R,
            'picL': picL,
            'picR': picR,
            'gradeL': getGradeEquivalent(L.rating),
            'gradeR': getGradeEquivalent(R.rating),
            'nuevoL': nuevoL,
            'nuevoR': nuevoR
            }
Beispiel #2
0
def showTop(gender=None):
    if gender is None or not gender in range(2):
        return redirect(url_for('home'))

    entries = sorted(db.session.query(Person).filter(and_(Person.gender == gender, Person.hidden == False)).all(), key=lambda x: x.rating, reverse=True)[:20]
    picSizes = [400 for x in entries]
    picSizes[0] = 700
    picSizes[1] = 600
    picSizes[2] = 500

    pics = [getProfilePictureLocation(x) for i, x in enumerate(entries)]
    grades = [getGradeEquivalent(x.rating) for x in entries]

    print "user <%s> accessed the %s top" % (getIP(), ['girls', 'boys'][gender])

    return render_template(
            'top.html',
            entries=entries,
            grades=grades,
            howMany=len(entries),
            pics=pics,
            totalVotes=getTotalVotes(),
            uniqueVoters=getUniqueVoters(),
            currentTheme=getCurrentTheme(),
            genderCount=getGenderCount(),
            themes=getThemes(),
            userIP=getIP()
            )
Beispiel #3
0
def showTop(gender=None):
    if gender is None or not gender in range(2):
        return redirect(url_for('home'))

    entries = sorted(db.session.query(Person).filter(
        and_(Person.gender == gender, Person.hidden == False)).all(),
                     key=lambda x: x.rating,
                     reverse=True)[:20]
    picSizes = [400 for x in entries]
    picSizes[0] = 700
    picSizes[1] = 600
    picSizes[2] = 500

    pics = [getProfilePictureLocation(x) for i, x in enumerate(entries)]
    grades = [getGradeEquivalent(x.rating) for x in entries]

    print "user <%s> accessed the %s top" % (getIP(), ['girls', 'boys'
                                                       ][gender])

    return render_template('top.html',
                           entries=entries,
                           grades=grades,
                           howMany=len(entries),
                           pics=pics,
                           totalVotes=getTotalVotes(),
                           uniqueVoters=getUniqueVoters(),
                           currentTheme=getCurrentTheme(),
                           genderCount=getGenderCount(),
                           themes=getThemes(),
                           userIP=getIP())
Beispiel #4
0
def drawChoices(wantedGender):
    pool = sorted(db.session.query(Person).filter(
        and_(Person.gender == wantedGender, Person.hidden == False,
             Person.facebookId != None)).all(),
                  key=lambda x: x.games)
    L, R = sample(
        pool[:100],
        2)  # at first, choices are selected from the least voted persons
    if randint(
            1, 2
    ) == 1:  # in order to guarantee variety, each choice has a 50% chance
        L = choice(pool)  # of being re-chosen from the entire person pool
    if randint(1, 2) == 1:
        R = choice(pool)

    while L == R:
        R = choice(pool)

    # picL = solveRedirect(SETTINGS['basePic'] % (L.username, 500, 500))
    # picR = solveRedirect(SETTINGS['basePic'] % (R.username, 500, 500))
    # ^the solveRedirect method is EXTREMELY slow
    picL = getProfilePictureLocation(L)
    picR = getProfilePictureLocation(R)

    nuevoL = ' (nuev%s)' % ['a', 'o'][L.gender] if '8' in L.school else None
    nuevoR = ' (nuev%s)' % ['a', 'o'][R.gender] if '8' in R.school else None

    # disables showing "nueva"/"nuevo" for boboci
    nuevoL = None
    nuevoR = None

    return {
        'L': L,
        'R': R,
        'picL': picL,
        'picR': picR,
        'gradeL': getGradeEquivalent(L.rating),
        'gradeR': getGradeEquivalent(R.rating),
        'nuevoL': nuevoL,
        'nuevoR': nuevoR
    }