def userPage(userID): try: #get info for other user profileUser = User.query.get(userID) starsIssued = len(profileUser.issued) print starsIssued starsReceived = len(profileUser.stars) print starsReceived otherUser = userPageUser.userPageUser(profileUser.firstName, profileUser.lastName, userID) otherUser.addStarsCount(starsIssued, starsReceived) #get info for this user if current_user.is_authenticated(): me = User.query.get(current_user.get_id()) thisUser = userPageUser.userPageUser(me.firstName, me.lastName, me.id) p = page.Page("Check out this user!", False) if thisUser.ID == otherUser.ID: ownPage = True if me.twitterUser is None: otherUser.twitterUser = True else: otherUser.twitterUser = False else: ownPage = False return render_template("users.html", user = thisUser, page = p, theOtherUser = otherUser, ownPage = ownPage) else: thisUser = None p = page.Page("Check out this user!", True) return render_template("users.html", user = thisUser, page = p, theOtherUser = otherUser, ownPage = False) except Exception as ex: print ex.message return redirect('/error')
def createUser(): p = page.Page("Sign Up!", True) try: userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, 0) except Exception as ex: thisUser = None return render_template("signup.html", page = p, user = thisUser)
def createUser(): p = page.Page("Sign Up!", True) try: userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, 0) except Exception as ex: thisUser = None return render_template("signup.html", page=p, user=thisUser)
def errorPage(): if current_user.is_authenticated(): p = page.Page("Oops!", False) userID = current_user.get_id() u = User.query.filter_by(id = userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName,u.id ) else: thisUser = None p = page.Page("Oops!", True) return render_template("error.html", page = p,user = thisUser)
def feedback(): if current_user.is_authenticated(): p = page.Page("Feedback!", False) userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, u.id) else: p = page.Page("Feedback!", True) thisUser = None return render_template("feedback.html", page = p, user = thisUser)
def errorPage(): if current_user.is_authenticated(): p = page.Page("Oops!", False) userID = current_user.get_id() u = User.query.filter_by(id=userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName, u.id) else: thisUser = None p = page.Page("Oops!", True) return render_template("error.html", page=p, user=thisUser)
def feedback(): if current_user.is_authenticated(): p = page.Page("Feedback!", False) userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, u.id) else: p = page.Page("Feedback!", True) thisUser = None return render_template("feedback.html", page=p, user=thisUser)
def userPage(userID): try: #get info for other user profileUser = User.query.get(userID) starsIssued = len(profileUser.issued) print starsIssued starsReceived = len(profileUser.stars) print starsReceived otherUser = userPageUser.userPageUser(profileUser.firstName, profileUser.lastName, userID) otherUser.addStarsCount(starsIssued, starsReceived) #get info for this user if current_user.is_authenticated(): me = User.query.get(current_user.get_id()) thisUser = userPageUser.userPageUser(me.firstName, me.lastName, me.id) p = page.Page("Check out this user!", False) if thisUser.ID == otherUser.ID: ownPage = True if me.twitterUser is None: otherUser.twitterUser = True else: otherUser.twitterUser = False else: ownPage = False return render_template("users.html", user=thisUser, page=p, theOtherUser=otherUser, ownPage=ownPage) else: thisUser = None p = page.Page("Check out this user!", True) return render_template("users.html", user=thisUser, page=p, theOtherUser=otherUser, ownPage=False) except Exception as ex: print ex.message return redirect('/error')
def mobileview_route(): if current_user.is_authenticated(): p = page.Page("Gold Star!", False) userID = current_user.get_id() u = User.query.filter_by(id = userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName, current_user.get_id()) if u.twitterUser is not None: thisUser.twitterUser = "******" else: thisUser.twitterUser = "******" return render_template('mobileview.html', page = p, user = thisUser) else: return redirect('login')
def mobileview_route(): if current_user.is_authenticated(): p = page.Page("Gold Star!", False) userID = current_user.get_id() u = User.query.filter_by(id=userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName, current_user.get_id()) if u.twitterUser is not None: thisUser.twitterUser = "******" else: thisUser.twitterUser = "******" return render_template('mobileview.html', page=p, user=thisUser) else: return redirect('login')
def login(): form = LoginForm() try: if form.validate_on_submit() and request.method == 'POST': username, password = form.username.data, form.password.data username = username.lower() user = User.query.filter_by(email=username).one() if bcrypt.hashpw(password, user.password) == user.password: login_user(user) if user.twitterUser is not None: resp = twitter.get('account/verify_credentials.json') if resp.status == 200: print "Twitter still Valid" elif resp.status == 401: print "Twitter Keys are Invalid" user.oauth_secret = None user.oauth_token = None user.twitterUser = None db.session.commit() return redirect('mobileview.html') elif request.method == 'POST': loginINFO = request.json user = User.query.filter_by( email=unicode(loginINFO['email'])).one() if bcrypt.hashpw(loginINFO['password'], user.password) == user.password: login_user(user) if user.twitterUser is not None: resp = twitter.get('account/verify_credentials.json') if resp.status == 200: print "Twitter still Valid" elif resp.status == 401: print "Twitter Keys are Invalid" user.oauth_secret = None user.oauth_token = None user.twitterUser = None db.session.commit() return jsonify(dict(id=current_user.get_id())) except Exception as ex: print ex.message flash('Invalid username or password') p = page.Page("Log in!", False) userID = current_user.get_id() if userID != None: u = User.query.filter_by(id=userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName, 0) else: thisUser = None return render_template("login.html", form=form, page=p, user=thisUser)
def settingsPage(): try: #get info for other user profileUser = User.query.get(current_user.get_id()) starsIssued = len(profileUser.issued) starsReceived = len(profileUser.stars) #get info for this user if current_user.is_authenticated(): me = User.query.get(current_user.get_id()) thisUser = userPageUser.userPageUser(me.firstName, me.lastName, me.id) p = page.Page("Settings!", False) ownPage = True return render_template("settings.html", user = thisUser, page = p) except Exception as ex: print ex.message return redirect('/error')
def login(): form = LoginForm() try: if form.validate_on_submit() and request.method == 'POST': username, password = form.username.data, form.password.data username = username.lower() user = User.query.filter_by(email = username).one() if bcrypt.hashpw(password, user.password) == user.password: login_user(user) if user.twitterUser is not None: resp = twitter.get('account/verify_credentials.json') if resp.status == 200: print "Twitter still Valid" elif resp.status == 401: print "Twitter Keys are Invalid" user.oauth_secret = None user.oauth_token = None user.twitterUser = None db.session.commit() return redirect('mobileview.html') elif request.method == 'POST': loginINFO = request.json user = User.query.filter_by(email = unicode(loginINFO['email'])).one() if bcrypt.hashpw(loginINFO['password'], user.password) == user.password: login_user(user) if user.twitterUser is not None: resp = twitter.get('account/verify_credentials.json') if resp.status == 200: print "Twitter still Valid" elif resp.status == 401: print "Twitter Keys are Invalid" user.oauth_secret = None user.oauth_token = None user.twitterUser = None db.session.commit() return jsonify(dict(id = current_user.get_id())) except Exception as ex: print ex.message flash('Invalid username or password') p = page.Page("Log in!", False) userID = current_user.get_id() if userID != None: u = User.query.filter_by(id = userID).one() thisUser = userPageUser.userPageUser(u.firstName, u.lastName,0) else: thisUser = None return render_template("login.html", form=form, page = p, user = thisUser)
def starPage(starID): try: s = Star.query.filter_by(id = starID).one() thisStar = StarObject.starObject(str(s.issuer.firstName + ' ' + s.issuer.lastName), str(s.owner.firstName + ' ' + s.owner.lastName), s.description,s.hashtag,s.created,s.issuer_id,s.owner_id) if current_user.is_authenticated(): userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, u.id) p = page.Page("Check out this star!", False) else: thisUser = None p = page.Page("Check out this star!", True) return render_template("star.html", star = thisStar, page = p, user = thisUser) except Exception as ex: print ex.message return redirect('/error')
def settingsPage(): try: #get info for other user profileUser = User.query.get(current_user.get_id()) starsIssued = len(profileUser.issued) starsReceived = len(profileUser.stars) #get info for this user if current_user.is_authenticated(): me = User.query.get(current_user.get_id()) thisUser = userPageUser.userPageUser(me.firstName, me.lastName, me.id) p = page.Page("Settings!", False) ownPage = True return render_template("settings.html", user=thisUser, page=p) except Exception as ex: print ex.message return redirect('/error')
def starPage(starID): try: s = Star.query.filter_by(id=starID).one() thisStar = StarObject.starObject( str(s.issuer.firstName + ' ' + s.issuer.lastName), str(s.owner.firstName + ' ' + s.owner.lastName), s.description, s.hashtag, s.created, s.issuer_id, s.owner_id) if current_user.is_authenticated(): userID = current_user.get_id() u = User.query.get(userID) thisUser = userPageUser.userPageUser(u.firstName, u.lastName, u.id) p = page.Page("Check out this star!", False) else: thisUser = None p = page.Page("Check out this star!", True) return render_template("star.html", star=thisStar, page=p, user=thisUser) except Exception as ex: print ex.message return redirect('/error')