def movieJSON(collection_id, movie_id):
    """ Returns a distinct album in JSON format
    :param collection_id:

    Args:
        movie_id:
    """
    collection = app.Collection().filter_by(id=collection_id).one()
    movie = app.Movie().filter_by(id=movie_id).one()
    return jsonify(movie=movie.serialize, collection=collection.serialize)
def showCollections():
    "Shows all movie collection in the database"

    collections = app.Collection().order_by(asc(Collection.name))
    if 'username' not in login_session:
        return render_template('publicCollections.html',
                               collections=collections)

    else:
        return render_template('showCollections.html', collections=collections)
def collectionsJSON():
    """ Returns all collections in JSON format. """
    collections = app.Collection().all()
    return jsonify(Collections=[c.serialize for c in collections])
def movieATOM(collection_id, movie_id):
    """ Returns a distinct album in Atom format """

    collection = app.Collection().filter_by(id=collection_id).one()
    movie = app.Movie().filter_by(id=movie_id).one()
    return render_template('movie.xml', movie=movie, collection=collection)
def collectionATOM(collection_id):
    """ Returns all albums of a distinct collection in Atom format. """

    collection = app.Collection().filter_by(id=collection_id).one()
    movies = app.Movie().filter_by(collection_id=collection_id).all()
    return render_template('movies.xml', movies=movies, collection=collection)
def collectionsATOM():
    """ Returns all collections in Atom format. """

    collections = app.Collection().all()
    return render_template('collections.xml', collections=collections)