def profile_history(username): # get info for author card card = prof_edit.get_card(username) # list of watchlist tables and files watchlists = [] # connect to database to get existing watchlist names conn = db.get_db() user_lists = conn.execute('''SELECT DISTINCT watchlist_name FROM IMDb_Watchlist WHERE username="******"'''.format(username=username)).fetchall() for ent in user_lists: watchlists.append(ent['watchlist_name']) # list of recent videos; restrict to 4 titles recents = [] # TESTING HARDCODE DUMMY recents.extend([{'imdbid':'tt0105236','title':'Reservoir Dogs','url':''}, {'imdbid':'tt4975722','title':'Moonlight','url':''}, {'imdbid':'tt0475784','title':'Westworld','url':''}, {'imdbid':'tt3322314','title':'Luke Cage','url':''}]) for rec in recents: rec['url'] = pi.get_poster_url_sql(rec['imdbid'],rec['title']) # dictionary containing page content page = {'watchlists': watchlists, 'recents': recents } return render_template('profile/profile-history.html', profile=card, page=page, username=username)
def profile_watchlist_each(username, watch_name): # get info for author card card = prof_edit.get_card(username) # watchlist name watchlist = prof_hist.parse_watchlist_for_page(username,watch_name) return render_template('/profile/profile-watchlist-each.html', profile=card, watch_name=watch_name, watchlist=watchlist, username=username)
def profile_linked(username): # get info for author card card = prof_edit.get_card(username) # get boolean statuses from sql linked = db.linked_account_status(username) # page = "Profile linked page" return render_template('profile/profile-linked.html', profile=card, linked=linked, username=username)
def profile_recommendation(username): # get info for author card card = prof_edit.get_card(username) # gets main content loaded onto screen page_content = pr.main(username) drops = ReccDropForm() drops.rent.choices.extend([([ind_cont['platform'],ind_cont['price']],ind_cont['title']) for ind_cont in page_content['indiv_rents']]) drops.buy.choices.extend([([ind_cont['platform'],ind_cont['price']],ind_cont['title']) for ind_cont in page_content['indiv_buys']]) # # individual rent forms # if request.method == 'POST': # return return render_template('profile/profile-recommendation.html', profile=card, service_recc=page_content['service_recc'], indiv_rents=page_content['indiv_rents'], indiv_buys=page_content['indiv_buys'], plat_content=page_content['plat_content'], drop_form=drops, username=username)
def profile_edit_bio(username): # get info for author card card = prof_edit.get_card(username) # get user existing bio bio = prof_edit.get_bio(username) # pack info for author card and page profile = {'username':username, 'fname': card['fname'], 'lname': card['lname'], 'join_month': card['join_month'], 'join_year': card['join_year'], 'bio': bio} if request.method == 'POST': bio_body = request.form['bio_body'] prof_edit.update_sql_bio(username, bio_body) return redirect(url_for('profile_edit', username=username)) return render_template('profile/profile-edit-bio.html', profile=profile, username=username)
def profile_linked_update(username): # get info for author card card = prof_edit.get_card(username) # get boolean statuses from sql linked = db.linked_account_status(username) # get form response to store updated info into database if request.method == 'POST': # posting information to database if request.form.get('amazon_prime') is not None: db.update_account_status(username,'linked_amazon',True) if request.form.get('netflix') is not None: db.update_account_status(username,'linked_netflix',True) if request.form.get('hbo') is not None: db.update_account_status(username,'linked_hbo',True) if request.form.get('hulu') is not None: db.update_account_status(username,'linked_hulu',True) return redirect(url_for('profile_linked', username=username)) return render_template('profile/profile-linked-update.html', profile=card, linked=linked, username=username)
def profile_edit(username): # get user bio bio = prof_edit.get_bio(username) # get user top three genre top_three = prof_edit.three_genre(prof_edit.ranked_genre(username)) # get information for author card card = prof_edit.get_card(username) # need to be able to edit author cards later profile = {'username':username, 'fname': card['fname'], 'lname': card['lname'], 'join_month': card['join_month'], 'join_year': card['join_year'], 'bio': bio, 'top_three':top_three} # page = prof_edit.main('profile/profile-edit.html', username) # return page return render_template('profile/profile-edit.html', profile=profile, username=username)
def profile_security(username): # get info for author card card = prof_edit.get_card(username) # connect to db conn = db.get_db() # dictionary for items to put into input boxes of page form_input = conn.execute('''SELECT username, password, email FROM all_user_data WHERE username="******"'''.format(username=username)).fetchone() form_dic = {'username':form_input['username'],'password':form_input['password'],'email':form_input['email']} # update database from submitting change to form if request.method == 'POST': # OH WHOOPS NEED TO ADDRESS DUPLICATES # update_username = conn.execute('''UPDATE all_user_data SET username="******" WHERE ''') update_password = conn.execute('''UPDATE all_user_data SET password="******" WHERE username="******"'''.format(password=request.form['password'], username=username)) update_email = conn.execute('''UPDATE all_user_data SET email="{email}" WHERE username="******"'''.format(email=request.form['email'],username=username)) return redirect(url_for('profile_security', username=username)) conn.close() return render_template('profile/profile-security.html', profile=card, username=username, form_dic=form_dic)
def profile_preferences(username): # get info for author card card = prof_edit.get_card(username) # page = "Profile preferences page" return render_template('profile/profile-preference.html', profile=card, username=username)
def profile_watchlist_add(username): # get info for author card card = prof_edit.get_card(username) return render_template('/profile/profile-watchlist-add.html', profile=card, username=username)