From b69132b5b782f26629ae42563c59688c1d057e3e Mon Sep 17 00:00:00 2001 From: Wout Schellaert Date: Thu, 26 Mar 2015 22:17:50 +0100 Subject: [PATCH] Removed imports --- app/admin.py | 5 ++--- app/app.py | 3 --- app/foodbot.py | 6 ------ app/login.py | 8 +++----- app/models.py | 4 ---- app/views.py | 5 ++--- app/zeus.py | 22 ++++------------------ 7 files changed, 11 insertions(+), 42 deletions(-) diff --git a/app/admin.py b/app/admin.py index a27c1ac..335e78f 100644 --- a/app/admin.py +++ b/app/admin.py @@ -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): diff --git a/app/app.py b/app/app.py index 09419eb..11bac36 100644 --- a/app/app.py +++ b/app/app.py @@ -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') diff --git a/app/foodbot.py b/app/foodbot.py index bc1a230..213b34a 100644 --- a/app/foodbot.py +++ b/app/foodbot.py @@ -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 * diff --git a/app/login.py b/app/login.py index 419a942..20fb494 100644 --- a/app/login.py +++ b/app/login.py @@ -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) diff --git a/app/models.py b/app/models.py index 01cfc41..5cbbc88 100644 --- a/app/models.py +++ b/app/models.py @@ -1,7 +1,3 @@ -import uuid -from datetime import date, timedelta - - from app import db # Create database models diff --git a/app/views.py b/app/views.py index 03a7692..d9401f0 100644 --- a/app/views.py +++ b/app/views.py @@ -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('/') diff --git a/app/zeus.py b/app/zeus.py index aed492d..b3a0c1b 100644 --- a/app/zeus.py +++ b/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)