def remove_c(): if mysession.check_session() == 'passed': username = session['username'] name = request.form["circle"] return circle_remove(username, name, g.db) else: return render_template('login.html', bad_session=True)
def unfriend_event(): if mysession.check_session() == 'passed': username = session['username'] other = request.form["other"] return unfriend(username, other, g.db) else: return render_template('login.html', bad_session=True)
def uploaded_file(user, filename): if mysession.check_session() == 'passed': return send_from_directory(os.path.join(app.config['UPLOAD_FOLDER'], user), filename) else: flash("You must login to access images") return redirect(url_for('logout'))
def edit_post_images(): if mysession.check_session() == 'passed': username = session['username'] postid = request.form["postid"] return e_post_images(username, postid, g.db) else: return render_template('login.html', bad_session=True)
def add_post_circles(): if mysession.check_session() == 'passed': username = session['username'] cid = request.form["circle"] postid = request.form["postid"] return a_post_circles_db(username, cid, postid, g.db) else: return render_template('login.html', bad_session=True)
def logout(): if mysession.check_session() == 'passed': username = session['username'] mysession.logout(username) session.clear() return render_template('login.html') else: return render_template('login.html', bad_session=True)
def change_info_event(): if mysession.check_session() == 'passed': username = session['username'] form = request.form file = request.files['file'] change_user_info(username, form, g.db, file) return render_template('change_user_success.html') else: return render_template('login.html', bad_session=False)
def add_f(): if mysession.check_session() == 'passed': username = session['username'] name = request.form["name"] circle = request.form["circle"] # print("user:"******" name:"+name+" circle: "+ circle) return circle_add_f(username, name, circle, g.db) else: return render_template('login.html', bad_session=True)
def create_post_page(): if mysession.check_session() == 'passed': username = session['username'] if not request.args.get("album"): return create_post_page_db(username, g.db) else: album = request.args.get("album") return create_post_page_db(username, g.db, album) else: return render_template('login.html', bad_session=True)
def friend_request_sent(): if mysession.check_session() == 'passed': requested = request.form["request"] if user_exists(requested): if request_friend(requested): return render_template('friend_request_sent.html', now_friend=True) else: return render_template('friend_request_sent.html', now_friend=False) else: return render_template('friend_request_page.html', bad_user=True) else: return render_template('login.html', bad_session=True)
def create_post(): if mysession.check_session() == 'passed': username = session['username'] postTitle = request.form["postTitle"] postText = request.form["postText"] print(postText) picture_list = request.form.getlist("pictures") if picture_list: return create_post_db(username, postTitle, postText, g.db, picture_list) else: return create_post_db(username, postTitle, postText, g.db) else: return render_template('login.html', bad_session=True)
def change_password(): oldPass = request.form['oldPassword'] newPass1 = request.form['newPassword1'] newPass2 = request.form['newPassword2'] username = session['username'] if mysession.check_session() == 'passed': if check_password(username, oldPass, g.db) == "passed": if newPass1 == newPass2: change_password_db(username, newPass1, g.db) return render_template('change_password_success.html') else: return render_template('change_password_page.html', bad_match=True) else: return render_template('change_password_page.html', bad_password=True) else: return render_template('login.html', bad_session=False)
def request_friend(friend): if mysession.check_session() == 'passed': c = g.db.cursor() username = session['username'] status = entry_exists(username, friend) if status == 'none': data = (username, friend, 0) sql = "INSERT INTO friends (user1, user2, status) VALUES(?,?,?)" c.execute(sql, data) g.db.commit() return False elif status == 'accept': data = (1, username, friend, friend, username) sql = "UPDATE friends SET status = ? WHERE (user1 = ? and user2 = ?) or (user1 = ? and user2 = ?)" c.execute(sql, data) g.db.commit() return True elif status == 'friends': return True return False
def upload(): if mysession.check_session() == 'passed': albums = pictures.get_albums() cur_album = None selected = request.args.get('selected') if selected is not None: cur_album = selected elif albums: cur_album = albums[0]['name'] images = pictures.get_pictures(session['username'], cur_album) if request.method == "GET": return render_template("upload.html", albums=albums, images=images) else: if 'privacy' in request.form: pictures.create_album(request.form) return redirect(url_for('upload')) # return render_template("upload.html", albums=albums, images=images) else: file = request.files['file'] album = request.form['album'] return pictures.upload_image(file, album) else: return render_template('login.html', bad_session=True)
def app_return(): if mysession.check_session() == 'passed': username = session['username'] return render_template("picture_options.html", user=username) else: return render_template('login.html', bad_session=True)
def change_info_page(): if mysession.check_session() == 'passed': username = session['username'] return change_info_get(username, g.db) else: return render_template('login.html', bad_session=False)
def friend_request_page(): if mysession.check_session() == 'passed': return render_template("friend_request_page.html") else: return render_template('login.html', bad_session=True)
def user_data_get(user): if mysession.check_session() == 'passed': username = session['username'] return get_data(username, user, g.db) else: return render_template('login.html', bad_session=True)
def new_home_page(): if mysession.check_session() == 'passed': username = session['username'] return home_page(username, g.db) else: return render_template('login.html', bad_session=True)
def friends_page(): if mysession.check_session() == 'passed': username = session['username'] return friends_data(username, g.db, False) else: return render_template('login.html', bad_session=True)
def circles_page(): if mysession.check_session() == 'passed': username = session['username'] return circles_page_db(username, g.db, False, False) else: return render_template('login.html', bad_session=True)
def your_posts(): if mysession.check_session() == 'passed': username = session['username'] return your_posts_home(username, g.db) else: return render_template('login.html', bad_session=True)
def change_password_page(): if mysession.check_session() == 'passed': return render_template('change_password_page.html'); else: return render_template('login.html', bad_session=False)