Removed imports
This commit is contained in:
parent
051588fba9
commit
b69132b5b7
7 changed files with 11 additions and 42 deletions
|
@ -1,12 +1,11 @@
|
|||
from flask import url_for, redirect
|
||||
from flask.ext.admin import Admin, BaseView, expose
|
||||
from flask.ext.admin import Admin
|
||||
from flask.ext.admin.contrib.sqla import ModelView
|
||||
from flask.ext import login
|
||||
|
||||
|
||||
from app import app, db
|
||||
from models import User
|
||||
from utils import send_command
|
||||
|
||||
|
||||
|
||||
class ModelBaseView(ModelView):
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
from flask import Flask
|
||||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
from werkzeug.contrib.cache import SimpleCache
|
||||
|
||||
|
||||
from logbook import Logger
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config.Configuration')
|
||||
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
from app import app, db
|
||||
|
||||
from admin import admin
|
||||
from login import login_manager
|
||||
from models import *
|
||||
from utils import start_process
|
||||
from views import *
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
from flask import redirect, request, url_for, abort, session
|
||||
from flask import redirect, abort, session, url_for
|
||||
from flask.ext.login import LoginManager, current_user, logout_user
|
||||
from flask_oauthlib.client import OAuth
|
||||
|
||||
import requests
|
||||
|
||||
from app import app, db, logger, cache
|
||||
from app import app
|
||||
from models import User
|
||||
from zeus import oauth, zeus_login
|
||||
from zeus import zeus_login
|
||||
|
||||
login_manager = LoginManager()
|
||||
login_manager.init_app(app)
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
import uuid
|
||||
from datetime import date, timedelta
|
||||
|
||||
|
||||
from app import db
|
||||
|
||||
# Create database models
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from flask import Blueprint, request, jsonify, redirect, url_for
|
||||
|
||||
from flask import url_for, render_template
|
||||
|
||||
from app import app
|
||||
from login import before_request
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
|
22
app/zeus.py
22
app/zeus.py
|
@ -1,13 +1,12 @@
|
|||
from flask import Flask, redirect, url_for, session, request, jsonify, flash, request
|
||||
from flask.ext.login import LoginManager, login_user, current_user, logout_user
|
||||
from flask.ext.admin import helpers
|
||||
from flask import redirect, url_for, session, jsonify, flash, request
|
||||
from flask.ext.login import login_user
|
||||
from flask_oauthlib.client import OAuth, OAuthException
|
||||
import json
|
||||
import requests
|
||||
|
||||
|
||||
from app import app, db
|
||||
from models import User, Token
|
||||
from models import User
|
||||
|
||||
oauth = OAuth(app)
|
||||
|
||||
|
@ -30,7 +29,7 @@ def zeus_login():
|
|||
return zeus.authorize(callback='http://zeus.ugent.be/foodbot/login/zeus/authorized')
|
||||
|
||||
|
||||
@app.route('/slotmachien/login/zeus/authorized')
|
||||
@app.route('/foodbot/login/zeus/authorized')
|
||||
def authorized():
|
||||
resp = zeus.authorized_response()
|
||||
if resp is None:
|
||||
|
@ -63,22 +62,9 @@ def get_zeus_oauth_token():
|
|||
|
||||
def login_and_redirect_user(user):
|
||||
login_user(user)
|
||||
# add_token(resp['access_token'], user)
|
||||
content_type = request.headers.get('Content-Type', None)
|
||||
if content_type and content_type in 'application/json':
|
||||
token = add_token(user)
|
||||
return jsonify({'token': token.token})
|
||||
return redirect(url_for("admin.index"))
|
||||
|
||||
|
||||
def add_token(user):
|
||||
token = Token()
|
||||
token.configure(user)
|
||||
db.session.add(token)
|
||||
db.session.commit()
|
||||
return token
|
||||
|
||||
|
||||
def create_user(username):
|
||||
user = User()
|
||||
user.configure(username, False)
|
||||
|
|
Loading…
Reference in a new issue