Ejemplo n.º 1
0
def get_user_level(request, username):
    print "^^^^^^^^^^^^^^"
    if username:

        p = Person()
        score = p.get_participation(username)
        score = score[0][0]

        print score

        if score == 0 or username=='anonymous':
            print "Hola, mundo!!"
            jd = {"user_level": {"score":0, "level":0}}
            j = json.dumps(jd)
            print j

        else:
            ranking=get_level(score)
            print score
            print ranking
        

            jd = {"user_level": {"score":score, "level":ranking}}


            j = json.dumps(jd)

        
        
    return HttpResponse(j, content_type='application/json')
Ejemplo n.º 2
0
def get_user_level(request, username):
    print "^^^^^^^^^^^^^^"
    if username:

        p = Person()
        score = p.get_participation(username)
        score = score[0][0]

        print score

        if score == 0 or username == 'anonymous':
            print "Hola, mundo!!"
            jd = {"user_level": {"score": 0, "level": 0}}
            j = json.dumps(jd)
            print j

        else:
            ranking = get_level(score)
            print score
            print ranking

            jd = {"user_level": {"score": score, "level": ranking}}

            j = json.dumps(jd)

    return HttpResponse(j, content_type='application/json')
Ejemplo n.º 3
0
def get_liders(request):
    print "T_T"

    jd = {"leaders": []}
    p = Person()
    lider_board = p.get_lider_board()
    #ldier_board = score[0][0]

    print lider_board

    if lider_board:
        #   c = 0
        for lider in lider_board:

            user = lider[0]
            score = lider[1]
            ranking = get_level(score)

            de = {"user": user, "score": score, "ranking": ranking}
            print de
            jd["leaders"].append(de)

        j = json.dumps(jd)

    else:
        print "No lider board"

    return HttpResponse(j, content_type='application/json')
Ejemplo n.º 4
0
def get_liders(request):
    print "T_T"
    
    jd = {"leaders":[]}
    p = Person()
    lider_board = p.get_lider_board()
    #ldier_board = score[0][0]

    print lider_board
   
    if lider_board:
        #   c = 0
        for lider in lider_board:

            user = lider[0]
            score = lider[1]
            ranking=get_level(score)
            

            de = {"user":user, "score":score, "ranking":ranking}
            print de
            jd["leaders"].append(de)     

        
        j = json.dumps(jd) 
         
    else:
        print "No lider board"
        
        
    return HttpResponse(j, content_type='application/json')
Ejemplo n.º 5
0
def get_leaders(request):
    #print "T_T"
    
    jd = {"leaders":[]}
    p = Person()

    #Ask if there leader board
    lider_board = p.get_lider_board()
    #ldier_board = score[0][0]

   
    if lider_board:
        #   c = 0
        for lider in lider_board:
            
            # if c < len(lider_board):
            #     c = c + 1
            #     print c

            user = lider[0]
            score = lider[1]
            ranking=get_level(score)
            

            de = {"user":user, "score":score, "ranking":ranking}
            print de
            jd["leaders"].append(de)
            

        
        j = json.dumps(jd) 
        print "101010101001010101010101001"
        print lider_board
        print jd
        print j   
    else:
        print "No leader board"
        m = {"leader_board":"No leader board"}
        j =json.dumps(m)
        
        
    return HttpResponse(j, content_type='application/json')