Ejemplo n.º 1
0
    def setUp(self):
        self.app = Flask(__name__)
        self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
        db.init_app(self.app)
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        # These settings are not required for merge user tests
        self.app.config['LASTUSER_SERVER'] = 'http://lastuser.testing'
        self.app.config['LASTUSER_CLIENT_ID'] = 'client_id'
        self.app.config['LASTUSER_CLIENT_SECRET'] = 'client_secret'

        self.lastuser = Lastuser(self.app)
        self.lastuser.init_usermanager(UserManager(db, User, Team))

        db.create_all()  # The users_team table doesn't exist until UserManager is inited

        self.create_test_data()
Ejemplo n.º 2
0
from pytz import timezone
from flask import Flask
from flask_migrate import Migrate
from flask_rq2 import RQ
from flask_mail import Mail
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from flask_admin import Admin
import wtforms_json
from baseframe import baseframe, assets, Version
from ._version import __version__
import coaster.app


app = Flask(__name__, instance_relative_config=True)
lastuser = Lastuser()

mail = Mail()
rq = RQ()

# --- Assets ------------------------------------------------------------------

version = Version(__version__)
assets['boxoffice.css'][version] = 'css/app.css'
assets['boxoffice.js'][version] = 'js/scripts.js'


from . import extapi, views  # NOQA
from boxoffice.models import db, User, Item, Price, DiscountPolicy, DiscountCoupon, ItemCollection, Organization, Category, Invoice  # noqa
from siteadmin import OrganizationModelView, DiscountCouponModelView, InvoiceModelView  # noqa
Ejemplo n.º 3
0
from flask_rq import RQ
from flask_mail import Mail
from flask_redis import FlaskRedis
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
import coaster.app
from ._version import __version__


# First, make an app and config it

app = Flask(__name__, instance_relative_config=True, subdomain_matching=True)
app.static_folder = 'static'
mail = Mail()
lastuser = Lastuser()
redis_store = FlaskRedis()

# Second, setup assets
version = Version(__version__)

# Third, after config, import the models and views

from . import models, views  # NOQA
from .models import db  # NOQA

# Configure the app
coaster.app.init_app(app)
db.init_app(app)
db.app = app
migrate = Migrate(app, db)
Ejemplo n.º 4
0
from flask_assets import Bundle
from flask_rq import RQ
from flask_mail import Mail
from flask_redis import FlaskRedis
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
import coaster.app
from ._version import __version__

# First, make an app and config it

app = Flask(__name__, instance_relative_config=True)
app.static_folder = 'static'
mail = Mail()
lastuser = Lastuser()
redis_store = FlaskRedis()

# Second, setup assets
version = Version(__version__)

# Third, after config, import the models and views

from . import models, views  # NOQA
from .models import db  # NOQA

# Configure the app
coaster.app.init_app(app)
db.init_app(app)
db.app = app
migrate = Migrate(app, db)
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-

# The imports in this file are order-sensitive
from __future__ import absolute_import
from flask import Flask
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
import coaster.app

version = Version('0.1.0')

# First, make an app

app = Flask(__name__, instance_relative_config=True)
lastuser = Lastuser()

# Second, import the models and views

from . import models, views
from .models import db, commentease

# Third, setup baseframe and assets

assets['hasnew.js'][version] = 'js/app.js'
assets['hasnew.css'][version] = 'css/app.css'


# Configure the app
def init_for(env):
    coaster.app.init_app(app, env)
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-

# The imports in this file are order-sensitive

from pytz import timezone
from flask import Flask
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
from flask_migrate import Migrate
import coaster.app
from ._version import __version__

version = Version(__version__)
app = Flask(__name__, instance_relative_config=True)
lastuser = Lastuser()

from . import models, views
from .models import db

assets['kharcha.css'][version] = 'css/app.css'

# Configure the app
coaster.app.init_app(app)
migrate = Migrate(app, models.db)
baseframe.init_app(app, requires=['baseframe', 'jquery.expander', 'kharcha'])
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(models.db, models.User, models.Team))
app.config['tz'] = timezone(app.config['TIMEZONE'])
Ejemplo n.º 7
0
            if host in self.hosts:
                return self.app
            else:
                return self.eventapp

    def __call__(self, environ, start_response):
        app = self.get_application(environ['HTTP_HOST'])
        return app(environ, start_response)


# Second, make the main and event apps

version = baseframe.Version(__version__)
app = Flask(__name__, instance_relative_config=True)
eventapp = SandboxedFlask(__name__, instance_relative_config=True, template_folder='themes-templates')
lastuser = Lastuser()

# Third, import models, nodes and views

import eventframe.models
import eventframe.nodes
eventframe.nodes.init()
import eventframe.views

from eventframe.models import db  # NOQA

# Fourth, setup baseframe, assets and theme assets on both apps
baseframe.assets['eventframe.css'][version] = 'css/app.css'
eventassets = ThemeAwareEnvironment(eventapp)

Ejemplo n.º 8
0
# -*- coding: utf-8 -*-

# The imports in this file are order-sensitive

from pytz import timezone
from flask import Flask
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
from flask_migrate import Migrate
import coaster.app
from ._version import __version__

version = Version(__version__)
app = Flask(__name__, instance_relative_config=True)
lastuser = Lastuser()

from . import models, views
from .models import db

assets['kharcha.css'][version] = 'css/app.css'


# Configure the app
coaster.app.init_app(app)
migrate = Migrate(app, models.db)
baseframe.init_app(app, requires=['baseframe', 'jquery.expander', 'kharcha'])
lastuser.init_app(app)
lastuser.init_usermanager(UserManager(models.db, models.User, models.Team))
app.config['tz'] = timezone(app.config['TIMEZONE'])
Ejemplo n.º 9
0
class TestMergeUserData(unittest.TestCase):
    def setUp(self):
        self.app = Flask(__name__)
        self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
        self.app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
        db.init_app(self.app)
        self.ctx = self.app.test_request_context()
        self.ctx.push()
        # These settings are not required for merge user tests
        self.app.config['LASTUSER_SERVER'] = 'http://lastuser.testing'
        self.app.config['LASTUSER_CLIENT_ID'] = 'client_id'
        self.app.config['LASTUSER_CLIENT_SECRET'] = 'client_secret'

        self.lastuser = Lastuser(self.app)
        self.lastuser.init_usermanager(UserManager(db, User, Team))

        db.create_all()  # The users_team table doesn't exist until UserManager is inited

        self.create_test_data()

    def tearDown(self):
        db.session.rollback()
        db.drop_all()
        self.ctx.pop()

    def create_test_data(self):
        user1 = User(userid=u"1234567890123456789012", username=u"user1", fullname=u"User 1",
            email=u'*****@*****.**',
            userinfo={
                u'timezone': u'Asia/Kolkata',
                u'organizations': {
                    u'member': [
                        {
                            u'userid': u'qazwsxedcrfvtgbyhnujmi',
                            u'name': u'org1',
                            u'title': u'Organization 1',
                            },
                        ],
                    u'owner': [
                        {
                            u'userid': u'qazwsxedcrfvtgbyhnujmi',
                            u'name': u'org1',
                            u'title': u'Organization 1',
                            },
                        ]
                    }
                })
        user2 = User(userid=u"0987654321098765432109", username=u"user2", fullname=u"User 2",
            email=u'*****@*****.**',
            userinfo={
                u'timezone': u'Asia/Kolkata',
                u'organizations': {
                    u'member': [
                        {
                            u'userid': u'qwertyuiopasdfghjklzxc',
                            u'name': u'org2',
                            u'title': u'Organization 2',
                            },
                        {
                            u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
                            u'name': u'org3',
                            u'title': u'Organization 3',
                            },
                        ],
                    u'owner': [
                        {
                            u'userid': u'qwertyuiopasdfghjklzxc',
                            u'name': u'org2',
                            u'title': u'Organization 2',
                            },
                        {
                            'userid': 'mnbvcxzlkjhgfdsapoiuyt',
                            'name': 'org3',
                            'title': 'Organization 3',
                            },
                        ]
                    }
                })
        user3 = User(userid=u"1234567890987654321234", username=u"user3", fullname=u"User 3",
            email=u'*****@*****.**',
            userinfo={
                u'timezone': 'Asia/Kolkata',
                u'organizations': {
                    u'member': [
                        {
                            u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
                            u'name': u'org3',
                            u'title': u'Organization 3',
                            },
                        {
                            u'userid': u'qazwsxedcrfvtgbyhnujmi',
                            u'name': u'org1',
                            u'title': u'Organization 1',
                            },
                        ],
                    u'owner': [
                        {
                            u'userid': u'mnbvcxzlkjhgfdsapoiuyt',
                            u'name': u'org3',
                            u'title': u'Organization 3',
                            },
                        {
                            u'userid': u'qazwsxedcrfvtgbyhnujmi',
                            u'name': u'org1',
                            u'title': u'Organization 1',
                            },
                        ]
                    }
                })

        team1 = Team(userid=u"1324354657687980089786", orgid=u"qazwsxedcrfvtgbyhnujmi",
            title=u"Team 1", users=[user1, user2])
        team2 = Team(userid=u"0897867564534231243546", orgid=u"qwertyuiopasdfghjklzxc",
            title=u"Team 2", users=[user2, user3])
        team3 = Team(userid=u"1324354657687980132435", orgid=u"mnbvcxzlkjhgfdsapoiuyt",
            title=u"Team 3", users=[user3, user1])

        db.session.add_all([user1, user2, user3, team1, team2, team3])
        db.session.flush()

        # Create six profiles (3 users + 3 orgs)
        Profile.update_from_user(user1, db.session)
        Profile.update_from_user(user2, db.session)
        Profile.update_from_user(user3, db.session)

        db.session.commit()
Ejemplo n.º 10
0
from flask import Flask
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from flask_mail import Mail
from flask_assets import Environment, Bundle
from baseframe import baseframe, assets, Version
from flask_migrate import Migrate
import coaster.app
from ._version import __version__

# First, make an app and config it

version = Version(__version__)
leaflet_version = Version('0.3.0')
app = Flask(__name__, instance_relative_config=True)
lastuser = Lastuser()
mail = Mail()

# Second, after config, import the models and views

import hacknight.models
from hacknight.models import db
import hacknight.views

# Third, setup baseframe and assets

assets['leaflet.css'][leaflet_version] = 'js/leaflet/leaflet.css'
assets['leaflet.js'][leaflet_version] = 'js/leaflet/leaflet.js'
assets['hacknight.css'][version] = 'css/app.css'
assets['hacknight.js'][version] = 'js/scripts.js'