Removed imports

This commit is contained in:
Wout Schellaert 2015-03-26 22:17:50 +01:00
parent 051588fba9
commit b69132b5b7
7 changed files with 11 additions and 42 deletions

View file

@ -1,12 +1,11 @@
from flask import url_for, redirect from flask.ext.admin import Admin
from flask.ext.admin import Admin, BaseView, expose
from flask.ext.admin.contrib.sqla import ModelView from flask.ext.admin.contrib.sqla import ModelView
from flask.ext import login from flask.ext import login
from app import app, db from app import app, db
from models import User from models import User
from utils import send_command
class ModelBaseView(ModelView): class ModelBaseView(ModelView):

View file

@ -1,10 +1,7 @@
from flask import Flask from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.sqlalchemy import SQLAlchemy
from werkzeug.contrib.cache import SimpleCache
from logbook import Logger
app = Flask(__name__) app = Flask(__name__)
app.config.from_object('config.Configuration') app.config.from_object('config.Configuration')

View file

@ -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 * from views import *

View file

@ -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.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 models import User
from zeus import oauth, zeus_login from zeus import zeus_login
login_manager = LoginManager() login_manager = LoginManager()
login_manager.init_app(app) login_manager.init_app(app)

View file

@ -1,7 +1,3 @@
import uuid
from datetime import date, timedelta
from app import db from app import db
# Create database models # Create database models

View file

@ -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 app import app
from login import before_request
@app.route('/') @app.route('/')

View file

@ -1,13 +1,12 @@
from flask import Flask, redirect, url_for, session, request, jsonify, flash, request from flask import redirect, url_for, session, jsonify, flash, request
from flask.ext.login import LoginManager, login_user, current_user, logout_user from flask.ext.login import login_user
from flask.ext.admin import helpers
from flask_oauthlib.client import OAuth, OAuthException from flask_oauthlib.client import OAuth, OAuthException
import json import json
import requests import requests
from app import app, db from app import app, db
from models import User, Token from models import User
oauth = OAuth(app) oauth = OAuth(app)
@ -30,7 +29,7 @@ def zeus_login():
return zeus.authorize(callback='http://zeus.ugent.be/foodbot/login/zeus/authorized') 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(): def authorized():
resp = zeus.authorized_response() resp = zeus.authorized_response()
if resp is None: if resp is None:
@ -63,22 +62,9 @@ def get_zeus_oauth_token():
def login_and_redirect_user(user): def login_and_redirect_user(user):
login_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")) 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): def create_user(username):
user = User() user = User()
user.configure(username, False) user.configure(username, False)