Exemple #1
0
def del_watchlist(list_name):
    db = Watchlist()
    username = session['__auth']
    if not db.check_watchlist(username, list_name):
        return render_template('404.html')
    list_id = db.get_list_id(username, session['__auth'], list_name)
    db.delete_watchlist(list_id)
    return redirect(url_for("watchlists", username=username))
Exemple #2
0
def add_filmInList(list_name, film_id):
    db = Watchlist()
    username = session['__auth']
    if not db.check_watchlist(username, list_name):
        return render_template('404.html')
    list_id = db.get_list_id(username, session['__auth'], list_name)
    db.add_film(list_id, film_id)
    return redirect(url_for('movie', film_id=film_id))
Exemple #3
0
def list_films(username, list_name):
    db = Watchlist()
    list_id = db.get_list_id(session['__auth'], username, list_name)
    if list_id is None:
        return render_template('404.html')
    films, watchlist = db.watchlist_films(list_id)
    return render_template('list_films.html', list_name=list_name, films=films,
                           username=username, watchlists=watchlist)
Exemple #4
0
def update_list(list_name):
    username = session["__auth"]
    form = UpdateList(username, list_name)
    db = Watchlist()
    username = session['__auth']
    if not db.check_watchlist(username, list_name):
        return render_template('404.html')
    elif form.validate_on_submit():
        list_title = form.title.data
        body = form.content.data
        list_id = db.get_list_id(username, session['__auth'], list_name)
        db.update_watchlist(list_id, list_title, body, username)
        return redirect(url_for("watchlists", username=username))
    form.title.data = list_name
    form.content.data = db.get_list_body(username, list_name)
    return render_template('newlist.html', form=form, title="Update Flow")
Exemple #5
0
def new_filmInlist(film_id):
    username = session["__auth"]
    form = WatchlistForm(username)
    db = Watchlist()
    if form.validate_on_submit():
        list_name = form.title.data
        body = form.content.data
        if request.form.get("mycheckbox"):
            db.add_watchlist(username, list_name, body)
            list_id = db.get_list_id(username, session['__auth'], list_name)
            db.add_film(list_id, film_id)
        else:
            db.add_watchlist(username, list_name, body)
        return redirect(url_for("movie", film_id=film_id))
    return render_template('newlist.html', form=form,
                           title="New Flow", checkbox=True)