Esempio n. 1
0
def configure_login(app):
    login_manager.login_view = 'qa.index'
    login_manager.refresh_view = 'qa.index'
    login_manager.login_message = None
    login_manager.session_protection = "basic"

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(id)

    login_manager.setup_app(app)
Esempio n. 2
0
def configure_extensions(app):
    db.init_app(app)

    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.login'

    @login_manager
    def load_user(id):
        pass  # TODO: make it works
        #return user.query.get(id)

    login_manager.setup_app(app)
    csrf.init_app(app)
Esempio n. 3
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = 'en'
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        return g.lang or request.accept_languages.best_match(accept_languages)

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Esempio n. 4
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = 'en'
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        return g.lang or request.accept_languages.best_match(accept_languages)

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Esempio n. 5
0
def configure_extensions(app):
        # flask-sqlalchemy
    db.init_app(app)

    # Sentry
    if app.config['SENTRY_DSN']:
        sentry.init(app, dsn=app.config['SENTRY_DSN'])

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.login'
    login_manager.anonymous_user = Anonymous

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(id)
    login_manager.setup_app(app)
Esempio n. 6
0
def configure_extensions(app):
    # flask-sqlalchemy
    db.init_app(app)

    # Sentry
    if app.config['SENTRY_DSN']:
        sentry.init(app, dsn=app.config['SENTRY_DSN'])

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(id)

    login_manager.setup_app(app)
Esempio n. 7
0
def configure_extensions(app):
    # flask-sqlalchemy
    db.init_app(app)

    # Sentry
    if app.config["SENTRY_DSN"]:
        sentry.init(app, dsn=app.config["SENTRY_DSN"])

    # flask-login
    login_manager.login_view = "frontend.login"
    login_manager.refresh_view = "frontend.reauth"

    @login_manager.user_loader
    def load_user(id):
        return User.query.get(id)

    login_manager.setup_app(app)
Esempio n. 8
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug and app.config['DEBUG_TB_PROFILER_ENABLED']:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = app.config.get('BABEL_DEFAULT_LOCALE')
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        # Try to guess the language from the user accept
        # header the browser transmits. We support ar/fr/en,
        # The best match wins.

        g.lang = session.get('language', None) or \
            request.accept_languages.best_match(accept_languages) or \
            g.lang

        if g.lang == 'ar':
            g.lang_dir = 'rtl'
            g.layout_dir_class = 'right-to-left'
            g.language_name = u'العربية'
        else:
            g.lang_dir = 'ltr'
            g.layout_dir_class = 'left-to-right'
            g.language_name = 'English' if g.lang == 'en' else u'Français'

        return g.lang

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)
Esempio n. 9
0
app.secret_key = 'secret key'

# flask-sqlalchemy
db.init_app(app)

# flask-login
# login_manager.login_view = 'frontend.index'
# login_manager.refresh_view = 'frontend.index'


@login_manager.user_loader
def load_user(id):
    return User.query.get(id)


login_manager.setup_app(app)

with app.app_context():
    # db.drop_all(bind=None)
    db.create_all(bind=None)

base_route = 'http://api.themoviedb.org/3/'
api_key = '21191bb1a231eae99a7864b641d45dc3'


@app.route('/')
def renderPage():
    """
  When the server first starts, route to the home page
  """
    return render_template("index.html")
Esempio n. 10
0
def configure_extensions(app):
    # flask-mongoengine
    db.init_app(app)
    app.session_interface = MongoEngineSessionInterface(db)
    # flask-mail
    mail.init_app(app)

    # flask-babel
    babel.init_app(app)

    # Bcrypt for hashing passwords
    bcrypt.init_app(app)

    # the Gravatar service
    gravatar.init_app(app)

    # Markdown
    md.init_app(app)

    # Caching
    cache.init_app(app)

    # Debug Toolbar
    if app.debug and app.config['DEBUG_TB_PROFILER_ENABLED']:
        from flask_debugtoolbar import DebugToolbarExtension
        DebugToolbarExtension(app)

    @babel.localeselector
    def get_locale():
        """
        Get the current request locale.

        returns String

        """
        if not hasattr(g, 'lang'):
            g.lang = app.config.get('BABEL_DEFAULT_LOCALE')
        accept_languages = app.config.get('ACCEPT_LANGUAGES')
        # Try to guess the language from the user accept
        # header the browser transmits. We support ar/fr/en,
        # The best match wins.

        g.lang = session.get('language', None) or \
            request.accept_languages.best_match(accept_languages) or \
            g.lang

        if g.lang == 'ar':
            g.lang_dir = 'rtl'
            g.layout_dir_class = 'right-to-left'
            g.language_name = u'العربية'
        else:
            g.lang_dir = 'ltr'
            g.layout_dir_class = 'left-to-right'
            g.language_name = 'English' if g.lang == 'en' else u'Français'

        return g.lang

    # flask-login
    login_manager.login_view = 'frontend.login'
    login_manager.refresh_view = 'frontend.reauth'

    @login_manager.user_loader
    def load_user(user_id):
        return User.objects(id=user_id).first()

    login_manager.setup_app(app)