def list_tvshows(): """ Lists all the tvshows in your media server Can do this without a login """ # # Check if the user is logged in, if not: back to login. # if('logged_in' not in session or not session['logged_in']): # return redirect(url_for('login')) global allmovies global alltvshows page['title'] = 'List TV Shows' # Get a list of all tvshows from the database alltvshows = None alltvshows = database.get_alltvshows() # Data integrity checks if alltvshows == None: alltvshows = [] # Data integrity checks if allmovies == None: allmovies = [] if alltvshows == None: alltvshows == [] return render_template('listitems/listtvshows.html', session=session, page=page, user=user_details, alltvshows=alltvshows, allmovies = allmovies)
def search_all(): """ Extension: power search autocomplete """ data = [] movies = database.get_allmovies() songs = database.get_allsongs() artists = database.get_allartists() genre = database.get_all_genre() podcasts = database.get_allpodcasts() tvshows = database.get_alltvshows() for instance in movies: data.append(instance['movie_title']) for instance in songs: data.append(instance['song_title']) for instance in artists: data.append(instance['artist_name']) for instance in genre: data.append(instance['md_value']) for instance in podcasts: data.append(instance['podcast_title']) for instance in tvshows: data.append(instance['tvshow_title']) return json.dumps(data, encoding='utf-8')
def index(): """ Provides the main home screen if logged in. - Shows user playlists - Shows user Podcast subscriptions - Shows superUser status """ # Check if the user is logged in, if not: back to login. if ('logged_in' not in session or not session['logged_in']): return redirect(url_for('login')) page['title'] = 'User Management' # Get a list of user playlists user_playlists = None user_playlists = database.user_playlists(user_details['username']) # Get a list of subscribed podcasts user_subscribed_podcasts = None user_subscribed_podcasts = database.user_podcast_subscriptions( user_details['username']) # Get a list of in-progress items user_in_progress_items = None user_in_progress_items = database.user_in_progress_items( user_details['username']) # Data integrity checks if user_playlists == None: user_playlists = [] if user_subscribed_podcasts == None: user_subscribed_podcasts = [] if user_in_progress_items == None: user_in_progress_items = [] global allmovies # for fuzzy search --- movies allmovies = database.get_allmoviesName() global alltvshows # for fuzzy search --- tvshows alltvshows = database.get_alltvshows() # Data integrity checks if allmovies == None: allmovies = [] if alltvshows == None: alltvshows == [] return render_template('index.html', session=session, page=page, user=user_details, playlists=user_playlists, subpodcasts=user_subscribed_podcasts, usercurrent=user_in_progress_items, allmovies=allmovies, alltvshows=alltvshows)
def add_tvshow(): """ Add a new TV show """ # # Check if the user is logged in, if not: back to login. if ('logged_in' not in session or not session['logged_in']): return redirect(url_for('login')) page['title'] = 'TV Show Creation' if bool(database.is_superuser([user_details['username']])) == False: flash("You do not have access to this feature.") alltvshows = database.get_alltvshows() return render_template('listitems/listtvshows.html', session=session, page=page, user=user_details, alltvshows=alltvshows) else: tvshows = None print("request form is:") newdict = {} print(request.form) # Check your incoming parameters if (request.method == 'POST'): # verify that the values are available: if ('tvshow_title' not in request.form): newdict['tvshow_title'] = 'Empty TV show title value' else: newdict['tvshow_title'] = request.form['tvshow_title'] print("We have a value: ", newdict['tvshow_title']) if ('description' not in request.form): newdict['description'] = 'Empty description field' else: newdict['description'] = request.form['description'] print("We have a value: ", newdict['description']) if ('artwork' not in request.form): newdict[ 'artwork'] = 'https://user-images.githubusercontent.com/24848110/33519396-7e56363c-d79d-11e7-969b-09782f5ccbab.png' else: newdict['artwork'] = request.form['artwork'] print("We have a value: ", newdict['artwork']) print('newdict is:') print(newdict) #forward to the database to manage insert tvshows = database.add_tvshow_to_db(newdict['tvshow_title'], newdict['description']) max_tvshow_id = database.get_last_tvshow()[0]['tvshow_id'] print(tvshows) if tvshows is not None: max_tvshow_id = tvshows[0] # ideally this would redirect to your newly added movie return single_tvshow(max_tvshow_id) else: return render_template('createitems/createtvshow.html', session=session, page=page, user=user_details)