Ejemplo n.º 1
0
def render_specific_search_results(keyword):
    """Serve up search results based on user's specific input parameters"""

    current_user = crud.get_user_by_email(session['email'])
    # current_user_prefs = get_current_user_preferences(current_user)
    current_user_preferred_genres = crud.get_user_genre_preferences_active(
        current_user)
    all_genres = crud.get_stored_genres()

    search_result = crud.get_movies_by_title(keyword)

    if search_result != None:
        flash(f"    {keyword}")
        session['render-search-results'] = "many"
        return render_template("homepage.html",
                               user=current_user,
                               user_genres=current_user_preferred_genres,
                               all_genres=GENRES,
                               languages=LANGUAGES,
                               current_recommendations=search_result)

    else:
        flash(f"...crickets chirping....  	🦗")
        flash(f"try a different search term, {session['name']}?")
        return redirect('/')
Ejemplo n.º 2
0
def read_movies_by_title(t: str, db: Session = Depends(get_db)):
    # read movies from database
    movies = crud.get_movies_by_title(db=db, title=t)
    # return them as json
    if movies is None:
        raise HTTPException(status_code=404, detail="Movie to read not found")
    # return movies
    return movies
Ejemplo n.º 3
0
def create_movie(movie: schemas.MovieCreate, db: Session = Depends(get_db)):
    db_movie = crud.get_movies_by_title(db, title=movie.title)
    if db_movie:
        raise HTTPException(
            status_code=400,
            detail="Movie already registered with the following title : %s" %
            title)
    return crud.create_movie(db=db, movie=movie)
Ejemplo n.º 4
0
def read_movies_by_title(t: str, db: Session = Depends(get_db)):
    return crud.get_movies_by_title(db=db, title=t)
Ejemplo n.º 5
0
def read_movies_by_title(n: Optional[str] = None,
                         db: Session = Depends(get_db)):
    # read movies from database
    movies = crud.get_movies_by_title(db=db, title=n)
    # return them as json
    return movies