def index(): v_ = Videos.query.all() videos_json = [video.serialize() for video in v_] if google_auth.is_logged_in(): if request.method == "POST": return render_template("index.html", links=videos_json, google_authenticated=True, authenticated=True, doc="ULabs Voting Space", user_info=google_auth.get_user_info()) else: return render_template("index.html", links=videos_json, doc="ULabs Voting Space", google_authenticated=True, user_info=google_auth.get_user_info()) elif request.method == "POST" and not google_auth.is_logged_in(): return redirect(url_for('login')) else: if google_auth.is_logged_in(): return render_template( "index.html", links=videos_json, doc="ULabs Voting Space", google_authenticated=True, ) else: return render_template("index.html", links=videos_json, doc="ULabs Voting Space", google_authenticated=False)
def index(): global user if google_auth.is_logged_in() and user is None: user_info = google_auth.get_user_info() user = dao.get_user_by_id(user_info['id']) if user is None: user = dao.create_user( User(user_info['id'], user_info['given_name'], user_info['family_name'], user_info['picture'])) elif not google_auth.is_logged_in() and user is not None: user = None return render_template('search_layout.html', labels=ALL_LABELS, profile=user)
def upload(photo=None, res=None): import model import output import urllib import json userdata = None if google_auth.is_logged_in(): userdata = google_auth.get_user_info() #I think its a dict else: return redirect('/google/login') if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part', 'danger') return redirect(request.url) file = request.files['file'] # if user does not select file, browser also # submit a empty part without filename if file.filename == '': flash('No selected file') return redirect(request.url) if file: filename = secure_filename(file.filename) file.save( os.path.join(application.config['UPLOAD_FOLDER'], filename)) flip = model.photoReshapei( os.path.join(application.config['UPLOAD_FOLDER'], filename)) # print('Photo flip: {:}'.format(flip)) photoProcess = os.path.join(application.config['UPLOAD_FOLDER'], 'Processed', filename) try: ip = request.environ.get( 'HTTP_X_FORWARDED_FOR') or request.environ.get( 'REMOTE_ADDR') # ip = '97.115.130.44' locurl = 'https://tools.keycdn.com/geo.json?host={:}'.format( ip) #its more complicated than this response = urllib.request.urlopen(locurl) ipdata = json.load(response)['data']['geo'] if not ipdata['city']: ipdata = {} except: ipdata = {} iswb = output.screen(photoProcess, flip=flip) if iswb: res = output.predict(photoProcess, flip=flip, ipdata=ipdata) #go get the photo either way photo = os.path.join(application.config['UPLOAD_FOLDER'], 'Processed', 'output', filename) output.upload(iswb, fn=os.path.join(application.config['UPLOAD_FOLDER'], 'Processed', filename), ipdata=ipdata, userdata=userdata) return render_template('upload.html', photo=photo)
def doGoogleLogout(self): if google_auth.is_logged_in(): google_token = google_auth.get_google_access_token() after = { "recommended_delay_ms": 1000, "actions": [{ "behavior": "logout", "logout_link": f'./google/logout/{google_token}' }] } resp = api_frame.wrapContent("[구글로그아웃] 구글로그아웃을 실행합니다", after, type="logout_message") else: after = { "recommended_delay_ms": 1000, "actions": [{ "behavior": "logout", "logout_link": "./" }] } # not redirecting now resp = api_frame.wrapContent("[구글로그아웃] 현재 로그인이 되어있지 않습니다.", after, type="logout_message") return resp
def index(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return '<div>You are currently logged in as ' + user_info[ 'given_name'] + '<div><pre>' + json.dumps(user_info, indent=4) + "</pre>" return render_template("/index.html")
def _secured(*args, **kwargs): if google_auth.is_logged_in(): pass else: #return redirect(url_for('/google/login', next=request.url)) return redirect("/google/login") return f(*args, **kwargs)
def view_bookings(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() email = user_info['email'] picture = user_info['picture'] name = user_info['name'] array_2d = View_Booking_By_Time(email) array_3d = View_Booking_By_Event(email) if request.method == "GET": return render_template('view-bookings.html', email=email, picture=picture, name=name, events_2d=array_2d, events_3d=array_3d, view_type="event") else: view_type = request.form.get("view_type") return render_template('view-bookings.html', email=email, picture=picture, name=name, events_2d=array_2d, events_3d=array_3d, view_type=view_type) # Format [ [Start_Time, End_Time, Meet_Who, Ref_Code, Date] ] else: return redirect(url_for("google_auth.login"))
def bookingCreate(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() email = user_info['email'] picture = user_info['picture'] name = user_info['name'] if request.method == 'GET': return render_template('booking-create.html', email=email, picture=picture, name=name) elif request.method == 'POST': if '""' in request.form['create-booking'] \ or 'Select Duration' in request.form['create-booking']: # some fields not selected error = 'Error with booking. Please try again.' return render_template('booking-create.html', email=email, picture=picture, name=name, error=error) array_2d = json.loads(request.form['create-booking']) ref_code = create_event(array_2d, email, name) return render_template("confirmation.html", email=email, picture=picture, name=name, refCode=ref_code) else: return redirect(url_for("google_auth.login"))
def cred(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return flask.render_template('list.html', user_info) return 'You are not currently logged in.'
def causal_impact(): if google_auth.is_logged_in(): return flask.render_template("causalimpact.html", title='Causal Impact Graph', user_info=google_auth.get_user_info()) return flask.render_template('index.html')
def signup_google(): error = None if not google_auth.is_logged_in(): return "Error 401: Unauthorised" else: google_id = session["google_id"] app.logger.debug( "checking if gid:" + str(google_id) + " of type " + str(type(google_id)) + " exists" ) if db.existing_google_id(google_id): app.logger.debug("google_id alr exists") return check_google_session() if request.method == "GET": return app.send_static_file("register_google.html") # @TODO enforce valid username app.logger.debug(dict(request.form)) username = request.form["username"] user_pattern = re.compile("^[a-z0-9_]{3,15}$") if not bool(user_pattern.match(username)): return "invalid username. username must match ^[a-z0-9_]{3,15}$" password = request.form["username"] display_name = request.form["display_name"] # @TODO catch errors user_id = db.create_user(username, password, display_name, True) db.create_google_user(session["google_id"], user_id, username) create_user_session(user_id) return redirect(url_for("home"))
def top_up(): if request.method == 'POST': user_info = google_auth.get_user_info() user_email = str(user_info['email']) balance = session.query(Accounts).filter_by(email=user_email).one() nb = balance.balance amount = request.form['amount'] # request.form['name'] new_balance = session.query(Accounts).filter_by(email=user_email).one() print(new_balance.email) new_amount = int(new_balance.balance) + int(amount) new_balance.balance = new_amount session.commit() # session.close() return jsonify({ "status": "works", "amount": new_amount, "id": new_balance.email }) else: if google_auth.is_logged_in(): return render_template("topup.html", user_info=google_auth.get_user_info()) else: return flask.render_template('logged.html')
def img(page): try: if google_auth.is_logged_in(): return render_template(f"{page}.svg") return 'You are not currently logged in.' except Exception as ex: logging.error(ex)
def index(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return render_template('index.html', user_info=google_auth.get_user_info()) return 'You are not currently logged in.'
def change_coffee_settings(): try: if google_auth.is_logged_in(): global server """ Check if the values are correct """ user_info = google_auth.get_user_info() client_data = request.get_json() coffee_left_threshold = float( client_data["coffee_left_threshold"]) * 1000.0 delivery_time = int(client_data["delivery_time"]) mail_supplier = client_data["mail_supplier"] client_data["coffee_left_threshold"] = str(coffee_left_threshold) client_data["mail_message"] = client_data["mail_message"].replace( '\n', '<br>') """ Check if all values are valid """ if coffee_left_threshold > 0 and coffee_left_threshold <= 90000 and delivery_time > 0 and delivery_time <= 111 and len( mail_supplier) > 0: server.coffee.change_settings(client_data, user_info["id"]) else: return jsonify({'status': False}) return jsonify({'status': True}) return authorization_error except Exception as ex: logging.error(ex) return jsonify({'status': False})
def index(): if google_auth.is_logged_in(): return redirect('/dashboard') else: return redirect('/google/login') return 'You are not currently logged in.'
def team_denied(team_number, pick_number): # check if logged in w/ google if not google_auth.is_logged_in(): return (redirect(url_for("google_auth.login"))) user_info = google_auth.get_user_info() user = User.query.filter(User.user_id == user_info["id"]).first() team = Team.query.filter_by(team_number=team_number).first() alliance_suggestion = AllianceSuggestion.query.filter( AllianceSuggestion.team_id == team.id, AllianceSuggestion.pick_number == pick_number).first() # toggle alliance suggestion based on state if alliance_suggestion.denied == True: alliance_suggestion.denied = False else: alliance_suggestion.denied = True alliance_suggestion.accepted = False alliance_suggestion.already_selected = False db.session.commit() return (redirect(url_for("alliance_suggestions.display_suggestions")))
def suggest_team(team_number, pick_number): # check if logged in w/ google if not google_auth.is_logged_in(): return (redirect(url_for("google_auth.login"))) user_info = google_auth.get_user_info() user = User.query.filter(User.user_id == user_info["id"]).first() team = Team.query.filter_by(team_number=team_number).first() if not team: team = Team(team_number=team_number) db.session.add(team) alliance_suggestion = AllianceSuggestion.query.filter( AllianceSuggestion.team_id == team.id, AllianceSuggestion.pick_number == pick_number).first() if alliance_suggestion: db.session.delete(alliance_suggestion) db.session.commit() else: alliance_suggestion = AllianceSuggestion(team_id=team.id, user_id=user.id, pick_number=pick_number) db.session.add(alliance_suggestion) db.session.commit() return (redirect(url_for("team.profile", team_number=team_number)))
def index(): if google_auth.is_logged_in(): return render_template('logout.html') #user_info = google_auth.get_user_info() #return '<div>You are currently logged in as ' + user_info['given_name'] + '<div><pre>' + json.dumps(user_info, indent=4) + "</pre>" return render_template('quartile_googleAuth.html')
def get_box_info(box): try: if google_auth.is_logged_in(): return server.get_info_box(box) return authorization_error except Exception as ex: logging.error(ex) return "Error"
def get_meetingbox_status(): try: if google_auth.is_logged_in(): return jsonify({'status': server.status_meeting_box}) return authorization_error except Exception as ex: logging.error(ex) return "Error"
def js(page): try: if google_auth.is_logged_in(): return render_template(f"/js/{page}.js") return 'You are not currently logged in.' except Exception as ex: logging.error(ex) return "Error"
def index(): #Check if user is logged in if google_auth.is_logged_in(): #get user info user_info = google_auth.get_user_info() #use its info for the welcome page return json.dumps(user_info, indent=4) return 'You are not logged in'
def redirection(): error = None if google_auth.is_logged_in(): return check_google_session() if is_logged_in(): return redirect(url_for("home")) else: return redirect(url_for("login"))
def home(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() print "A user just logged in to the dashboard" + json.dumps(user_info, indent=4) return redirect("/yentel-dashboard", code=302) else: return redirect("/google/login", code=302)
def index(): try: if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return render_template("index.html", user_info=user_info) #return '<div>You are currently logged in as ' + user_info['given_name'] + '<div><pre>' + json.dumps(user_info, indent=4) + "</pre>" return redirect("/google/login") except Exception as ex: logging.error(ex)
def match(match_number): # check if logged in w/ google if not google_auth.is_logged_in(): return (redirect(url_for("google_auth.login"))) form = TeamSearchForm() match = Match.query.filter_by(match=match_number).join(MatchReport).first() return (render_template("match_scout/match.html", match=match, form=form))
def index(): if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return jsonify({ 'user_info': json.dumps(user_info, indent=4), 'message': 'You have logged in successfully' }) return jsonify({'message': 'You are not currently logged in.'})
def html(page): try: if google_auth.is_logged_in(): user_info = google_auth.get_user_info() return render_template(f"{page}.html", user_info=user_info) return redirect("/google/login") except Exception as ex: logging.error(ex) return "Error"
def ai_meeting(): try: if google_auth.is_logged_in(): global server status = server.change_ai_status("ai_meeting") socketio.emit('status_ai_meeting', {'status': server.status_ai["ai_meeting"]}) except Exception as ex: logging.error(ex)