예제 #1
0
파일: views.py 프로젝트: PelayoBesa/kaariOK
def changeRating(request, song_id ,new_status, action):
    # Delete current rating
    try:
        rating = Rating.objects.get(user=request.user, song=song_id);
        rating.delete()
    except:
        pass
        
    if action == 'switch':
        new_rating = Rating(user=request.user, song=Song.objects.get(id=song_id), value=new_status)
        new_rating.save()
    
    return song_detail(request, song_id, True)
예제 #2
0
def changeRating(request, song_id, new_status, action):
    # Delete current rating
    try:
        rating = Rating.objects.get(user=request.user, song=song_id)
        rating.delete()
    except:
        pass

    if action == 'switch':
        new_rating = Rating(user=request.user,
                            song=Song.objects.get(id=song_id),
                            value=new_status)
        new_rating.save()

    return song_detail(request, song_id, True)
예제 #3
0
# user ratings
c.execute('SELECT usr_id, kar_id, com_conocido FROM comentarios')
for rating in c:
    rate = ''
    if rating[2] == 'LOVE':
        rate = 'love'
    elif rating[2] == 'NO':
        rate = 'hate'
    elif rating[2] == 'SI':
        rate = 'known'
    elif rating[2] == 'NO SE':
        rate = 'hate'
    else:
        rate = None

    user = None
    if rating[0] == 'carlita':
        user = User.objects.get(username='******')
    elif rating[0] == 'pedratan':
        user = User.objects.get(username='******')
    else:
        user = None

    try: 
        comentario = Rating(user=user, song=songs[rating[1]], comment='', value=rate)
        comentario.save()
    except KeyError:
        pass

con.close()