def get(name): """ Return an movie key information based on his name """ m = MovieRepository.get(name=name) d = {} d['name'] = m.name d['year'] = m.year d['genre'] = m.genre d['notes'] = 0 d['affiche'] = m.affiche t = [] for l in m.notes: t.append(l.note) if len(t) != 0: d['notes'] = sum(t) / len(t) else: d['notes'] = -1 return (jsonify(d))
def get(user_id): """ Return an user key information based on his id """ user = UserRepository.get_from_id(user_id=user_id).json movie_ids = [ mark.movie_id for mark in MarkRepository.get_from_user_id( user_id=user["user_id"]) ] user["seen_movies"] = [ MovieRepository.get(movie_id=movie_id).json for movie_id in movie_ids ] for movie in user["seen_movies"]: movie["mark"] = MarkRepository.get( movie_id=movie["movie_id"], user_id=user["user_id"]).json["note"] movie["average_mark"] = MovieMeanResource.get( movie_id=movie["movie_id"]).json["average_mark"] return jsonify({"user": user})
def get(title, director): """ Return a movie key information based on his name """ movie = MovieRepository.get(title=title, director=director) return jsonify({"movie": movie.json})
def get(title): """ Return an movie key information based on his title """ movie = MovieRepository.get(title=title) return jsonify({"movie": movie.json})
def get(movie_id): """ Return a movie key information based on its id """ movie = MovieRepository.get(movie_id=movie_id).json movie["average_mark"] = MovieMeanResource.get( movie["movie_id"]).json["average_mark"] return jsonify({"movie": movie})