def forgotpwd(): config = web.get_config() if request.method == 'POST': useremail = request.form["user_email"] newpassword = request.form["user[password_forgot]"] manager = UserManager(web.get_db()) manager.changePasswordBynew(useremail, newpassword) return render_template("/inforPage.html", infor="Password change successfully, please login again.", **dict( gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY']), is_logged_in=web.is_logged_in(), user_email=session['u_email']) else: return render_template("/inforPage.html", infor="Password change failed.", **dict( gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY']), is_logged_in=web.is_logged_in(), user_email=session['u_email'])
def adminpage(): config = web.get_config() if 'u_email' in session: return render_template('/admin/adminpage.html', gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY'], is_logged_in=web.is_logged_in(), user_email=session['u_email']) return redirect('/')
def example_messenger(): config = web.get_config() if 'u_email' in session: return render_template('message_example.html', gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY'], is_logged_in=web.is_logged_in(), user_email=session['u_email']) return render_template('message_example.html')
def activity(): config = web.get_config() if 'u_email' in session: return render_template('activity/base.html', gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY'], is_logged_in=web.is_logged_in(), user_email=session['u_email']) return render_template("activity/base.html")
def user(): config = web.get_config() if 'u_email' in session: user_profile = web.get_current_user() playlist_manager = PlaylistManager(web.get_db()) playlists = playlist_manager.api_get_playlists() if user_profile.u_isadmin: return redirect('/admin/adminpage') return render_template('user.html', is_logged_in=web.is_logged_in(), user_email=user_profile.u_email, u_email=user_profile.u_email, u_firstname=user_profile.u_firstname, u_lastname=user_profile.u_lastname, u_genre=user_profile.u_genre, playlists=playlists) return redirect('/')
def activity_memory(): config = web.get_config() if request.method == 'POST': db = web.get_db() with db.session_scope() as sessions: Playlist.l_name = request.form["playlistTitle"] for track_detail in request.form.getlist('trackDetail'): detail = json.loads(track_detail) Track.t_title = detail['title'] Track.t_author = detail['author'] Track.t_url = detail['url'] sessions.commit() if 'u_email' in session: return render_template('memory.html', gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY'], is_logged_in=web.is_logged_in(), user_email=session['u_email']) else: return render_template( "index.html", **dict(gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY']))
def update_user_profile(): config = web.get_config() if request.method == 'POST': u_email = session['u_email'] new_firstname = request.form.get("new_fristname") new_lastname = request.form.get("new_lastname") new_genre = request.form.get("new_genre") password = request.form.get("password") new_password = request.form.get("new_password") print(new_lastname,new_firstname,new_genre) if UserManager(web.get_db()).update_profile(u_email, new_firstname, new_lastname, new_genre, password, new_password): return render_template("/inforPage.html", infor="Your profile was updated successfully!", **dict( gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY']), is_logged_in=web.is_logged_in(), user_email=session['u_email']) else: return render_template("/inforPage.html", infor="Failed to update your profile, please check and update again.", **dict( gauth_key=config['GAUTH_KEY'], fb_key=config['FB_KEY']), is_logged_in=web.is_logged_in(), user_email=session['u_email'])