Ejemplo n.º 1
0
 def create_app(self):
     app = create_web_app(**{
         'DEBUG': True,
         'TESTING': True,
         'SITE_TITLE': 'SpenDB',
         'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:',
         'PRESERVE_CONTEXT_ON_EXCEPTION': False,
         'CELERY_ALWAYS_EAGER': True
     })
     data_manager._coll = open_collection('test', 'file',
                                          path=tempfile.mkdtemp())
     return app
Ejemplo n.º 2
0
 def create_app(self):
     app = create_web_app(
         **{
             'DEBUG': True,
             'TESTING': True,
             'SITE_TITLE': 'SpenDB',
             'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:',
             'PRESERVE_CONTEXT_ON_EXCEPTION': False,
             'CELERY_ALWAYS_EAGER': True
         })
     data_manager._coll = open_collection('test',
                                          'file',
                                          path=tempfile.mkdtemp())
     return app
Ejemplo n.º 3
0
from spendb.core import create_web_app
from spendb.command import assets

app = create_web_app()

if not app.config.get('ASSETS_DEBUG'):
    with app.app_context():
        assets.auto_build = False
Ejemplo n.º 4
0
''' Interface to common administrative tasks for SpenDB. '''
import logging
from flask.ext.script import Manager
from flask.ext.assets import ManageAssets
from flask.ext.migrate import MigrateCommand

from spendb.core import create_web_app
from spendb.tasks import load_from_url
from spendb.assets import assets
from spendb.command import db
from spendb.command.importer import get_or_create_dataset, get_model

log = logging.getLogger(__name__.split('.')[0])
app = create_web_app()
manager = Manager(app, description=__doc__)

manager.add_command('db', db.manager)
manager.add_command('alembic', MigrateCommand)
manager.add_command('assets', ManageAssets(assets))


@manager.command
def grantadmin(username):
    """ Grant admin privileges to given user """
    from spendb.model import meta as db
    from spendb.model.account import Account

    account = Account.by_name(username)
    if account is None:
        raise Exception("Account `%s` not found." % username)