__init__.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from os import path
  2. from flask import Flask
  3. from flask_admin import Admin
  4. from flask_sqlalchemy import SQLAlchemy
  5. import sqlalchemy_defaults
  6. from flask_migrate import Migrate
  7. from flask_security import Security, SQLAlchemyUserDatastore
  8. from flask_bootstrap import Bootstrap
  9. from flask.ext.uploads import configure_uploads, patch_request_class
  10. from flask_thumbnails_s3 import Thumbnail
  11. from library.admin_utils import ProtectedAdminIndexView
  12. app = Flask(__name__,
  13. template_folder=path.abspath(
  14. path.join(path.dirname(__file__), '../templates')),
  15. static_folder=path.abspath(
  16. path.join(path.dirname(__file__), '../static')))
  17. app.config.from_object('project.settings')
  18. db = SQLAlchemy(app)
  19. db.Column = sqlalchemy_defaults.Column
  20. sqlalchemy_defaults.make_lazy_configured(db.mapper)
  21. migrate = Migrate(app, db, path.join(app.config['PROJECT_ROOT'], 'migrations'))
  22. from accounts.models import Role, User
  23. security = Security(app, SQLAlchemyUserDatastore(db, User, Role))
  24. Bootstrap(app)
  25. thumb = Thumbnail(app)
  26. from foo.uploads import upload_sets
  27. configure_uploads(app, upload_sets)
  28. patch_request_class(app)
  29. admin = Admin(app,
  30. name='%s Administration' % app.config['SITE_NAME'],
  31. index_view=ProtectedAdminIndexView(url='/admin'),
  32. template_mode='bootstrap3')
  33. import accounts.admin
  34. import foo.admin
  35. from foo.views import mod
  36. app.register_blueprint(mod)