def create__like(user_id, show_id): db = DbManager() like = Like() check = db.open().query(Like).filter(Like.user_id == user_id).filter(Like.show_id == show_id).all() if len(check) == 0: like.show_id = show_id like.user_id = user_id return db.save(like) return False
def create_like(user_id, movie_id): try: db = DbManager() movie = db.open().query(Movie).filter(Movie.api_id == movie_id).one() like = Like() like.user_id = user_id like.movie_id = movie.id db.save(like) return like except: pass
def like_tvshow(user_id, tvshow_id): user = get_user_by_id(user_id) tvshow_url = TVMAZE_URL.format('shows', tvshow_id) tvshow = get_tvshow_by_url(tvshow_url) DB = DbManager() try: exist = DB.open().query(Like).filter(Like.user_id == user_id, Like.tvshow_id == tvshow.id).one() return exist except: like = Like() like.user = user like.tvshow = tvshow DB.save(like) return like
def create_like(user_id, movie_id): messages = [] try: db.open().query(Like).filter(Like.user_id == user_id).filter( Like.movie_id == movie_id).one() messages.append('Movie ID {} already liked'.format(movie_id)) except: movie = get_movie_api_id(movie_id) like = Like() like.user_id = user_id like.movie_id = movie.id db.save(like) return like return messages
def like_film(user_id, film_id): db = DbManager() like = Like() like.user_id = user_id like.film_id = film_id return db.save(like)