def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash(f"User {username} not found!", "danger") return redirect(url_for("home")) if user == current_user: flash("You cannot unfollow you own profile.", "danger") return redirect(url_for("home", username=username)) current_user.unfollow(user) # unfollows db.session.commit() # save in database flash(f"You are not following {username} anymore.", "success") return redirect(url_for("user", username=username)) else: return redirect(url_for("home"))
def unfollow(username): form = EmptyForm() if form.validate_on_submit(): user = User.query.filter_by(username=username).first() if user is None: flash('user {} not found'.format(username)) return redirect(url_for('index')) if user == current_user: flash('you can\'t unfollow yourself!') return redirect(url_for('user', username=username)) current_user.unfollow(user) db.session.commit() flash('you are unfollowing {}'.format(username)) return redirect(url_for('user', username=username)) else: return redirect(url_for('index'))
def issue30(): form = EmptyForm( ) # Empty form, only validates the secret token to protect against cross-site scripting if request.method == 'POST' and form.validate(): try: hp.init_tmpo() tmpos = hp.get_tmpos() hp.sync_tmpos() tmpos.dbcon.close() except: flash("Error syncing TMPO, please try again later") else: flash("TMPO Sync Successful") return render_template('issue30.html', form=form)
def admin(): form = EmptyForm( ) # Empty form, only validates the secret token to protect against cross-site scripting if request.method == 'POST' and form.validate(): if request.form['submit'] == 'Sync TMPO': try: hp.sync_tmpos() except: flash("Error syncing TMPO, please try again later") else: flash("TMPO Sync Successful") elif request.form['submit'] == 'Reset Houseprint': hp.reset() flash("Houseprint Reset Successful") return render_template('admin.html', form=form)
def issue30(): form = EmptyForm() # Empty form, only validates the secret token to protect against cross-site scripting if request.method == 'POST' and form.validate(): try: hp.init_tmpo() tmpos = hp.get_tmpos() hp.sync_tmpos() tmpos.dbcon.close() except: flash("Error syncing TMPO, please try again later") else: flash("TMPO Sync Successful") return render_template( 'issue30.html', form=form )
def home(): if (session.get('logged-in')): if (session['username'][0] == 'A'): return redirect(url_for('ahome')) if (session['username'][0] == 'E'): return redirect(url_for('ehome')) session.pop('phone', False) form = EmptyForm() return render_template('index.html', form=form)
def admin(): form = EmptyForm() # Empty form, only validates the secret token to protect against cross-site scripting if request.method == 'POST' and form.validate(): if request.form['submit'] == 'Sync TMPO': try: hp.sync_tmpos() except: flash("Error syncing TMPO, please try again later") else: flash("TMPO Sync Successful") elif request.form['submit'] == 'Reset Houseprint': hp.reset() flash("Houseprint Reset Successful") return render_template( 'admin.html', form=form )
def profile(): if (not session.get('logged-in')): flash('LOGIN TO CONTINUE', 'danger') return redirect(url_for('logout')) session['up'] = 1 form = EmptyForm() full_filename = os.path.join(app.config['UPLOAD_FOLDER'], session['email'].lower()) return render_template('profile.html', dp=full_filename, form=form, dict1=dataret(session['email']))
def user(username): user = User.query.filter_by(username=username).first_or_404() page = request.args.get('page', 1, type=int) songs = user.songs.order_by(Song.timestamp.desc()).paginate( page, app.config['SONGS_PER_PAGE'], False) form = EmptyForm() next_url = url_for('user', username=user.username, page=songs.next_num) \ if songs.has_next else None prev_url = url_for('user', username=user.username, page=songs.prev_num) \ if songs.has_prev else None return render_template('user.html', user=user, songs=songs.items, form=form, next_url=next_url, prev_url=prev_url)
def user(username): user = User.query.filter_by(username=username).first_or_404() page = request.args.get("page", 1, type=int) posts = Post.query.filter_by(author=user).paginate( page, app.config["POSTS_PER_PAGE"], False ) next_url = url_for("user", username=user.username, page=posts.next_num) if posts.has_next else None prev_url = url_for("user", username=user.username, page=posts.prev_num) if posts.has_prev else None form = EmptyForm() return render_template( "user.html", title="User", user=user, posts=posts.items, next_url=next_url, prev_url=prev_url, form=form )
def classes(): form = EmptyForm() return render_template('classes.html', classes=CLASSES, form=form)
def user(user): form = EmptyForm() classeS = current_user.check_classes().all() return render_template('profile.html', classlist=classeS, form=form)
def userhome(): if (not session.get('logged-in')): flash('LOGIN to continue', 'danger') return redirect(url_for('login')) form = EmptyForm() return render_template('userhome.html', form=form, title="HOME")
def home(): form = EmptyForm() if (session.get('logged-in')): return redirect(url_for('userhome')) else: return render_template('index.html', form=form)
def WBO(): if (not session.get('logged-in')): flash('LOGIN first', 'danger') return redirect(url_for('login')) cursor = mysql.connection.cursor() #saving if request.method == 'POST': res = request.get_json(force=True) foldername = session['email'].lower().split('@') foldername = foldername[0] + foldername[1][:-4] path = os.path.join(os.getcwd(), 'static\\media\\wbd', foldername) if (not os.path.exists(path)): os.mkdir(path) drawing = dict() for i in range(len(res) - 1): drawing[f"stroke{i}"] = res[i] filename = res[-1]['filename'] print(filename) now = datetime.now() noww = now.strftime("%Y-%m-%d %H:%M:%S") with open(f'{path}/{filename}.json', 'w') as json_file: json.dump(drawing, json_file, indent=4) cursor.execute( f"select filename from wbd where filename='{filename}' and owned='{session['email'].lower()}'" ) a = cursor.fetchone() print(a) if a is None: cursor.execute( f"insert into wbd values('{session['email'].lower()}','{filename}','{noww}')" ) else: cursor.execute( f"update wbd set date_modified='{noww}' where owned='{session['email'].lower()}'" ) mysql.connection.commit() if (request.args.get('action')): action = request.args.get('action') if action == "create-new": return render_template("whiteboard.html") else: filename = request.args.get('filename') foldername = session['email'].split('@') foldername = foldername[0] + foldername[1][:-4] path = os.path.join(os.getcwd(), 'static\\media\\wbd', foldername) if (action == 'delete'): print(os.path.join(path, filename)) if (os.path.exists(os.path.join(path, f"{filename}.json"))): os.remove(os.path.join(path, f"{filename}.json")) cursor.execute( f"delete from wbd where owned='{session['email'].lower()}' and filename='{filename}'" ) mysql.connection.commit() return redirect(url_for('WBO')) if (action == 'open'): with open(f"{path}/{filename}.json") as f: data = json.load(f) points = [] for key, value in data.items(): stroke = value points.append(stroke) print(points) return render_template('whiteboard.html', data=points) cursor.execute( f"select * from wbd where owned='{session['email'].lower()}' order by date_modified desc" ) a = cursor.fetchall() #print(a) foldername = session['email'].lower().split('@') foldername = foldername[0] + foldername[1][:-4] path = f"media/wbd/{foldername}" return render_template('wbohead.html', form=EmptyForm(), title="Whiteboard", d=a, path=path)