コード例 #1
0
ファイル: update_user_fame.py プロジェクト: alexdiao/3805
def update_user_topic_fame(topic_id, current_user_id, added_score):
    """
    updates the *score* in User_Topic_Fame for the creator of an item that is tagged this topic
    """
    
    utf_current_set = User_Topic_Fame.objects.filter(user__pk=current_user_id, topic__pk=topic_id)
    if utf_current_set:
        utf_current = utf_current_set[0]
        utf_current.score = utf_current.score + added_score
        utf_current.save()
    else:
        utf_current = User_Topic_Fame()
        utf_current.topic_id = topic_id
        utf_current.user_id = current_user_id
        utf_current.score = added_score
        utf_current.save()
    
    return "success"