rearranged

This commit is contained in:
Oleg Podsadny 2013-06-09 23:19:15 +02:00
parent f22ad13e46
commit bb0fd73147
6 changed files with 42 additions and 34 deletions

View File

@ -1,20 +1,11 @@
from flask import Blueprint
from .decorators import public_endpoint
from .manager import login_manager, check_valid_login
from .models import db
__all__ = ['bp', 'db', 'public_endpoint']
bp = Blueprint('auth', __name__, template_folder='auth')
from .blueprint import auth
@bp.record_once
def on_registered(state):
db.init_app(state.app)
login_manager.init_app(state.app)
state.app.before_request(check_valid_login)
# Register views
import views
views
from .views import *
__all__ = ['auth', 'db', 'public_endpoint']

View File

@ -0,0 +1,14 @@
from flask import Blueprint
from .manager import login_manager, check_valid_login
from .models import db
auth = Blueprint('auth', __name__, template_folder='auth')
@auth.record_once
def on_registered(state):
db.init_app(state.app)
login_manager.init_app(state.app)
state.app.before_request(check_valid_login)

View File

@ -1,13 +1,13 @@
from flask import request, url_for, redirect, render_template
from flask.ext.login import login_user
from . import bp
from .blueprint import auth
from .decorators import public_endpoint
from .forms import LoginForm
from .models import User
@bp.route('/login/', methods=['GET', 'POST'])
@auth.route('/login/', methods=['GET', 'POST'])
@public_endpoint
def login():
form = LoginForm()

View File

@ -1,20 +1,4 @@
from flask import Flask
# from flask.ext.admin import Admin
from .app import app
from pytest_bdd_example.dashboard import settings
from pytest_bdd_example import auth
app = Flask(
__name__,
static_folder=settings.MEDIA_ROOT,
template_folder=settings.TEMPLATES_ROOT,
)
app.config.from_object('pytest_bdd_example.dashboard.settings')
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
app.register_blueprint(auth.bp, url_prefix='/auth')
__all__ = ['app']

View File

@ -0,0 +1,17 @@
from flask import Flask
from pytest_bdd_example.dashboard import settings
from pytest_bdd_example.auth import auth
app = Flask(
__name__,
static_folder=settings.MEDIA_ROOT,
template_folder=settings.TEMPLATES_ROOT,
)
app.config.from_object('pytest_bdd_example.dashboard.settings')
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
app.register_blueprint(auth, url_prefix='/auth')

View File

@ -1,5 +1,7 @@
from flask import render_template
from .app import app
@app.route('/')
def index(template='dashboard.html'):