Beispiel #1
0
def getNonArchivedMoviesForUser():
    session_id = request.args.get('session_id')
    user_id = request.args.get('user_id')
    if not Api.authenticate(user_id, session_id):
        raise Exception("Authentication failed")
    movies = Mapper.mapMovies(Api.getNonArchivedMoviesForUser(user_id))
    return json.dumps([json.dumps(p, cls=ObjectEncoder) for p in movies])
Beispiel #2
0
def archiveMovieForUser():
    session_id = request.args.get('session_id')
    user_id = request.args.get('user_id')
    if not Api.authenticate(user_id, session_id):
        raise Exception("Authentication failed")
    movie_id = request.args.get('movie_id')
    Api.archiveMovieForUser(movie_id, user_id)
    return json.dumps(json.dumps({'message': 'Done'}, cls=ObjectEncoder))
Beispiel #3
0
def getIMDBSuggestions():
    session_id = request.args.get('session_id')
    user_id = request.args.get('user_id')
    if not Api.authenticate(user_id, session_id):
        raise Exception("Authentication failed")
    title = request.args.get('title')
    movies = Api.getIMDBSuggestionsForTitle(title)
    string = json.dumps([json.dumps(p, cls=ObjectEncoder) for p in movies])
    return string
Beispiel #4
0
def saveMovie():
    session_id = request.args.get('session_id')
    user_id = request.args.get('user_id')
    if not Api.authenticate(user_id, session_id):
        raise Exception("Authentication failed")
    movie_title = request.args.get('movie_title')
    movie_year = request.args.get('movie_year')
    movie_imdb_id = request.args.get('movie_imdb_id')
    Api.saveMovie(movie_title, movie_year, movie_imdb_id)
    return json.dumps(json.dumps({'sessionId': session_id}, cls=ObjectEncoder))
Beispiel #5
0
def login():
    userEmail = request.args.get('emailId')
    password = request.args.get('password')
    session_id = Api.login(userEmail, password)
    if not session_id:
        raise Exception("Authentication failed")
    return json.dumps(json.dumps({'sessionId': session_id}, cls=ObjectEncoder))
Beispiel #6
0
def createUser():
    user_name = request.args.get('user_name')
    emailId = request.args.get('user_emailId')
    password = request.args.get('user_password')
    session_id = Api.createUser(user_name, password, emailId)
    print session_id
    if not session_id:
        raise Exception("Sorry, could not create user. User is already registered")
    return json.dumps(json.dumps({'sessionId': session_id}, cls=ObjectEncoder))