def profile(): if config.isLoggedIn(): return render_template('dashboard/profile.html', login=config.isLoggedIn(), id=session['id'], email=session['username'], name=session['name'], phone=session['phone'], score="#", tag="Beginner") else: return redirect(url_for('auth'))
def _aiwrite(dir): if isLoggedIn(): if dir in list(keymap.keys()): game = gm.hasGameWithId(session["uid"]) gm.shift(session["uid"], dir) back = printBoard(game, includeid=False) if game.last == back: game.times += 1 if game.times >= treshold: emit( "error", "no change in board state for " + str(treshold) + " turns,exiting...\nReload the page to start a new game" ) return else: game.times = 0 game.last = back uid = session["uid"] u = User.query.get(uid) g = Game.query.filter_by(user=u).order_by(db.desc( Game.start)).first() g.hightile = gm.getHightile(uid) g.points = gm.getPoints(uid) db.session.commit() emit("airead", back) emit("bupdate", str(session["uid"]) + " " + back, room=room) emit("score_update", getSessionScores(), room=room) else: emit( "error", "Invalid move, exiting...\nReload the page to start a new game" )
def history(): if config.isLoggedIn(): jsonobj = config.history().val() return render_template('dashboard/history.html', login=True, json=jsonobj) else: return redirect(url_for('auth'))
def home_my_form_post(): text = request.form['search'] try: ans = wp.summary(text, sentences=2) if (config.isLoggedIn()): config.historify(session['id'], text, request.remote_addr) return render_template('home.html', answer=ans, login=True) else: flash("Login to Save History and to get better search results", "info") return render_template('home.html', answer=ans, login=False) except: return render_template( 'home.html', answer= "Oh Ohh ... Sorry. I couldnt get that . will get that in next version", login=config.isLoggedIn())
def index(): if isLoggedIn(): scores = getSessionScores() if isGuest(): return render_template("index.html", guest=True, scores=scores) else: return render_template("index.html", guest=False, scores=scores) else: return redirect(url_for("login"))
def changepassword(): if config.isLoggedIn(): email = session['username'] if (config.reset_password_with_email(email)): flash("Password Reset Link has been sent to " + email + ".", "success") return redirect(url_for('profile')) else: flash( "Account Not Found. Please Check Email Address " + email + ".", "danger") return redirect(url_for('profile')) else: return redirect(url_for('auth'))
def _session(): if isLoggedIn() and isAdmin(): u = User.query.get(session["uid"]) form = SessionForm(request.form) if form.validate_on_submit(): s = Session(form.count.data) db.session.add(s) db.session.commit() return render_template("session.html", scores=getSessionScores(), user=u, form=form) else: return redirect(url_for("login"))
def _input(data): if not isLoggedIn(): return ev = data["key"] uid = session["uid"] if ev in list(keymap.keys()): gm.shift(uid, ev) u = User.query.get(uid) g = Game.query.filter_by(user=u).order_by(db.desc(Game.start)).first() g.hightile = gm.getHightile(uid) g.points = gm.getPoints(uid) db.session.commit() emit("bupdate", printBoard(gm.get(uid)), room=room) emit("score_update", getSessionScores(), room=room)
def conn(): if isLoggedIn(): uid = session["uid"] gm.removeTable(uid) ng = gm.hasGameWithId(uid) u = User.query.get(uid) g = Game(u) if ng == None: ng = cGame(logic.Game(), uid, u.nick) ng.game.new_game() gm.addTable(ng) db.session.add(g) db.session.commit() join_room(room) else: #Already playing (prevent multiple login) return False emit("player_connect", (uid, u.nick), room=room) emit("bupdate", printBoard(ng), room=room) emit("load_others", gm.getGames(uid))
def future(): if config.isLoggedIn(): return render_template('dashboard/future.html', login=True) else: return redirect(url_for('auth'))
def dc(): if isLoggedIn(): uid = session["uid"] leave_room(room) emit("player_disconnect", uid, room=room) gm.removeTable(uid)
def contact(): return render_template('contact.html', login=config.isLoggedIn())
def about(): return render_template('about.html', login=config.isLoggedIn())
def Register(): return render_template('register.html', login=config.isLoggedIn())
def _choose(): if isLoggedIn() and isAdmin(): u = User.query.get(session["uid"]) return render_template("choose.html", user=u) else: return redirect(url_for("login"))
def is_accessible(self): return isLoggedIn()
def home(): return render_template('home.html', answer="Hi there ....", login=config.isLoggedIn())
def ResetPassword(): return render_template('forgotpassword.html', login=config.isLoggedIn())
def howitworks(): return render_template('howitworks.html', login=config.isLoggedIn())
def page_not_found(e): return render_template('404.html', login=config.isLoggedIn())
def auth(): return render_template('login.html', login=config.isLoggedIn())
def dashboard(): if config.isLoggedIn(): return redirect(url_for('profile')) else: return redirect(url_for('auth'))