Beispiel #1
0
def home():
    form = SearchForm()
    # check if user login
    try:
        user = session['username']
        user = repo.db.get_user(user)

    except:
        user = None

    if form.validate_on_submit():
        keyword = form.keyword.data

        match, similar = repo.db.find(keyword)
        return render_template('General/search.html',
                               match=match,
                               similar=similar,
                               form=form)
    if user:
        return render_template('General/home.html',
                               MovieList2=repo.db.random_movie(
                                   user.preference),
                               MovieList1=repo.db.first_n_movie(),
                               form=form)
    return render_template('General/home.html',
                           MovieList2=repo.db.random_movie(),
                           MovieList1=repo.db.first_n_movie(),
                           form=form)
Beispiel #2
0
def comment():
    search_form = SearchForm()
    comment_form = CommentForm()

    # get movie id and find movie
    movie_id = request.args.get('id')
    movie_found = repo.db.find_movie(movie_id)

    # if not login yet
    # check if user login
    try:
        user = session['username']
        user = repo.db.get_user(user)
        if movie_found in user.favorite:
            user_like_movie = 1
        else:
            user_like_movie = 0
    except:
        return redirect(url_for('user_bp.login'))

    if comment_form.validate_on_submit():
        print(comment_form.comment.data)
        service.add_comment(movie_id, session['username'],
                            comment_form.comment.data, repo)

        return redirect(url_for('movie_bp.movie', id=movie_id))
    return render_template('MovieObject/movie.html',
                           form=search_form,
                           movie=movie_found,
                           is_commenting=True,
                           comment_form=comment_form,
                           user=user,
                           user_like_movie=user_like_movie)
Beispiel #3
0
def movie():
    search_form = SearchForm()
    comment_form = CommentForm()

    # get movie id and find movie
    movie_id = request.args.get('id')
    movie_found = repo.db.find_movie(movie_id)

    # check if user login
    try:
        user = session['username']
        user = repo.db.get_user(user)
        if movie_found in user.favorite:
            user_like_movie = 1
        else:
            user_like_movie = 0
    except:
        user = None
        user_like_movie = 0

    return render_template('MovieObject/movie.html',
                           form=search_form,
                           movie=movie_found,
                           is_commenting=None,
                           comment_form=comment_form,
                           user=user,
                           user_like_movie=user_like_movie)
Beispiel #4
0
def index():
    form = SearchForm()
    keyword = request.args.get('keyword')
    return render_template(
        "General/index.html",
        form=form,
        alphabet=repo.db.search_index(),
        dictionary=repo.db.sorted_dictionary(keyword=keyword))
Beispiel #5
0
def genre():
    form = SearchForm()
    genre = request.args.get('id')
    return render_template(
        "General/index.html",
        form=form,
        alphabet=repo.db.search_index(),
        dictionary=repo.db.genre_movie_dictionary(genre=genre)
    )
Beispiel #6
0
def people():
    form = SearchForm()
    people_id = request.args.get('id')
    person = repo.db.find_people(people_id)

    return render_template('MovieObject/people.html', form=form, people=person)