Esempio n. 1
0
    def init_app(self, app):

        if app.config.get("MODULE_USER_ACCOUNT_ENABLE_OAUTH_LOGIN"):
            secret = app.config.get("SECRET_KEY")
            providers = app.config.get("MODULE_USER_ACCOUNT_OAUTH_PROVIDERS")
            config = {}
            auth_providers = []

            for provider, conf in list(providers.items()):
                if hasattr(oauth2, provider):
                    cls = getattr(oauth2, provider)
                    conf[
                        "class_"] = conf["class_"] if "class_" in conf else cls
                elif hasattr(oauth1, provider):
                    cls = getattr(oauth1, provider)
                    conf[
                        "class_"] = conf["class_"] if "class_" in conf else cls
                else:
                    continue

                conf["id"] = provider_id()
                _provider = provider.lower()
                auth_providers.append(_provider)
                config[_provider] = conf

            self.oauth = Authomatic(config=config,
                                    secret=secret,
                                    session=session,
                                    report_errors=True)

            Juice.g(OAUTH_PROVIDERS=auth_providers)
Esempio n. 2
0
    def init_app(self, app):

        if app.config.get("MODULE_USER_ACCOUNT_ENABLE_OAUTH_LOGIN"):
            secret = app.config.get("SECRET_KEY")
            providers = app.config.get("MODULE_USER_ACCOUNT_OAUTH_PROVIDERS")
            config = {}
            auth_providers = []

            for provider, conf in providers.items():
                if hasattr(oauth2, provider):
                    cls = getattr(oauth2, provider)
                    conf["class_"] = conf["class_"] if "class_" in conf else cls
                elif hasattr(oauth1, provider):
                    cls = getattr(oauth1, provider)
                    conf["class_"] = conf["class_"] if "class_" in conf else cls
                else:
                    continue

                conf["id"] = provider_id()
                _provider = provider.lower()
                auth_providers.append(_provider)
                config[_provider] = conf

            self.oauth = Authomatic(
                config=config,
                secret=secret,
                session=session,
                report_errors=True
            )

            Juice.g(OAUTH_PROVIDERS=auth_providers)
Esempio n. 3
0
def test_contact_page():
    @extends(contact_page.contact_page)
    class Index(Juice):
        pass

    app = Juice.init(__name__, config=config)
    app.testing = True

    with app.test_client() as c:
        data = c.get("/contact").data
Esempio n. 4
0
def test_contact_page():

    @extends(contact_page.contact_page)
    class Index(Juice):
        pass

    app = Juice.init(__name__, config=config)
    app.testing = True

    with app.test_client() as c:
        data = c.get("/contact").data
Esempio n. 5
0
from flask import Flask
import flask_cache
import ses_mailer
import flask_mail
import flask_cloudy
import flask_recaptcha
from juice import Juice
from juice.ext import mail, cache, storage, recaptcha, csrf

conffile = "config.py"

_ = Juice(__name__, config=conffile)


# Recaptcha
def test_recaptcha():
    assert isinstance(recaptcha, flask_recaptcha.ReCaptcha)


# Storage
def test_storage():
    assert isinstance(storage, flask_cloudy.Storage)


# Cache
def test_cache():
    assert isinstance(cache, flask_cache.Cache)


# Mailer
def test_mailer_none():
Esempio n. 6
0
This is the entry point of the application.

--------------------------------------------------------------------------------

** To serve the local development app

> juicy serve {project_name}

#---------

** To deploy with Propel ( https://github.com/mardix/propel )

> propel -w

#---------

** To deploy with Gunicorn

> gunicorn app_{project_name}:app

"""

from juice import Juice

# Import the project's views
import application.{project_name}.views

# 'app' variable name is required if you intend to use 'juicy' the cli tool
app = Juice(__name__, project="{project_name}")

Esempio n. 7
0
    juicy user id 1

--------------------------------------------------------------------------------

"""

from juice import Juice, get_env_config, abort
import juice.utils as utils
from application import config, model
from juice.plugins import user, publisher
from juice.ext import mail
from juice.cli import cli, click

# init Juice without registering the views
Juice(__name__, skip_views=True)

# Load the config
conf = get_env_config(config)

# ------------------------------------------------------------------------------

def setup_db():
    """
    Setup models from model.py
    """
    model.db.create_all()

def setup_admin_user_publisher():
    """
    Setup Juice User and Publisher Admin