Esempio n. 1
0
 def change_badges(user, meal, level):
     # Userテーブルのtotal_badgesを変更
     user_table = User.query.filter(User.user_id == user).first()
     user_table.total_badges += 1
     # Badgesテーブルにカラム追加
     badges_table = Badge.query.filter(Badge.user_id == user,
                                       Badge.meal_id == meal).all()
     if len(badges_table) == 0:
         add_data(Badge(user, meal, level))
     else:
         print("level", level)
         badges_table[0].level = level
     db_session.commit()