Beispiel #1
0
    def test_sync_triggers(self):
        mock_manager = VersioningManager()
        mock_manager.options = {
            'table_name': 'custom_%s_versioning_table_scheme'
        }

        sync_trigger(self.connection,
                     'custom_article_versioning_table_scheme',
                     versioning_manager=mock_manager)
        assert ('DROP TRIGGER IF EXISTS article_trigger ON "article"'
                in QueryPool.queries[-4])
        assert 'DROP FUNCTION ' in QueryPool.queries[-3]
        assert 'CREATE OR REPLACE FUNCTION ' in QueryPool.queries[-2]
        assert 'CREATE TRIGGER ' in QueryPool.queries[-1]

        sync_trigger(self.connection,
                     'custom_article_versioning_table_scheme',
                     versioning_manager=mock_manager)
Beispiel #2
0
else:
    install_logging = False

naming_convention = {
    "ix": 'ix_%(column_0_label)s',
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(column_0_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s"
}
db = SQLAlchemy(metadata=MetaData(naming_convention=naming_convention))

cache = Cache()
csrf = CsrfProtect()
migrate = Migrate()
manager = VersioningManager(options={'strategy': 'subquery'})
make_versioned(manager=manager, plugins=[FlaskPlugin()])
mail = Mail()
cdn = CDN()
login_manager = LoginManager()
assets = Environment()
toolbar = DebugToolbarExtension()

assets.register(
    'css_main',
    Bundle('css/main.scss',
           output='gen/main-packed.css',
           depends='css/*.scss',
           filters='pyscss,cssmin'))
assets.register(
    'css_admin',
Beispiel #3
0
    if (type_, name, reflected) == ("table", "spatial_ref_sys", True):
        return False

    return True


# Force Quoted-Printable encoding for emails.
# The flask-mail package sets the header encoding to "SHORTEST" and the body encoding
# to None. Somehow this, combined with Postmark, results in the email body being wrapped
# twice, which results in ugly plaintext emails.
charset.add_charset("utf-8", charset.QP, charset.QP, "utf-8")

cache = Cache()
csrf = CSRFProtect()
migrate = Migrate(include_object=include_object)
manager = VersioningManager(options={"strategy": "subquery"})
make_versioned(manager=manager, plugins=[FlaskPlugin()])
mail = Mail()
login_manager = LoginManager()
static_digest = FlaskStaticDigest()
toolbar = DebugToolbarExtension()
gocardless_client = None
volunteer_admin = None


def create_app(dev_server=False, config_override=None):
    app = Flask(__name__)
    app.config.from_envvar("SETTINGS_FILE")
    if config_override:
        app.config.from_mapping(config_override)
    app.jinja_options["extensions"].append("jinja2.ext.do")
Beispiel #4
0
 def test_module_name_in_class_name(self):
     options = {'use_module_name': True}
     vm = VersioningManager(options=options)
     mb = ModelBuilder(vm, self.Article)
     ArticleVersion = mb.build_model(self.Article.__table__)
     assert ArticleVersion.__name__ == 'TestsArticleVersion'
Beispiel #5
0
Database model base classes.
"""

from sqlalchemy_continuum import make_versioned
from sqlalchemy_continuum.manager import VersioningManager
from sqlalchemy_continuum.plugins import PropertyModTrackerPlugin

from evalg import db
from evalg.database import audit
from evalg.database.formatting import PrimaryKeyRepr
from evalg.database.types import UtcDateTime, IpAddressType, UuidType

_model_repr = PrimaryKeyRepr(maxstring=50, maxother=50)

# Use our own Transaction factory
versioning_manager = VersioningManager(
    transaction_cls=audit.EvalgTransactionFactory())

make_versioned(
    manager=versioning_manager,
    user_cls='Person',
    plugins=[
        audit.audit_plugin,
        audit.meta_plugin,
        PropertyModTrackerPlugin(),
    ],
)


class ModelBase(db.Model):
    __abstract__ = True