diff --git a/.travis.yml b/.travis.yml index 1171f8f..4adf1e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,19 @@ language: python python: - "3.5.2" before_install: + - 'sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg' + - 'echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list' - 'travis_retry sudo apt-get update' - - 'travis_retry sudo apt-get install python3-dev libxml2-dev libxmlsec1-dev' + - 'travis_retry sudo apt-get install python3-dev libxml2-dev libxmlsec1-dev yarn' install: - pip install -r requirements.txt before_script: - - mv config_template.py config.py + - mv config_template.py config.py + - export FLASK_APP=app/__init__.py + - flask db upgrade + - yarn install --pure-lockfile + - flask assets build script: - - sh run_travis.sh \ No newline at end of file + - sh run_travis.sh +cache: + yarn: true diff --git a/app/__init__.py b/app/__init__.py index 805bf37..0a462b6 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -4,6 +4,7 @@ from flask_login import LoginManager from flask_sqlalchemy import SQLAlchemy as SA from flask_migrate import Migrate from flask_oauthlib.client import OAuth +from sqlalchemy.exc import OperationalError # subclass SQLAlchemy to enable pool_pre_ping class SQLAlchemy(SA): @@ -35,4 +36,9 @@ if app.config.get('SAML_ENABLED') and app.config.get('SAML_ENCRYPT'): if not certutil.check_certificate(): certutil.create_self_signed_cert() -from app import models, views +from app import models + +try: + from app import views +except OperationalError: + logging.error("You have not initialized the DB yet or DB migration is running...") diff --git a/app/templates/domain.html b/app/templates/domain.html index bb351db..ce435f2 100644 --- a/app/templates/domain.html +++ b/app/templates/domain.html @@ -267,7 +267,7 @@ applyChanges({'domain': domain}, $SCRIPT_ROOT + '/domain/' + domain + '/update'); }); - {% if SETTING.get('record_helper_setting') %} + {% if SETTING.get('record_helper') %} //handle wacky record types $(document.body).on("focus", "#current_edit_record_data", function (e) { var record_type = $(this).parents("tr").find('#record_type').val(); diff --git a/migrations/versions/59729e468045_add_view_column_to_setting_table.py b/migrations/versions/59729e468045_add_view_column_to_setting_table.py index 8fe195e..dbb6906 100644 --- a/migrations/versions/59729e468045_add_view_column_to_setting_table.py +++ b/migrations/versions/59729e468045_add_view_column_to_setting_table.py @@ -77,6 +77,11 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### + ## NOTE: + ## - Drop action does not work on sqlite3 + ## - This action touchs the `setting` table which loaded in views.py + ## during app initlization, so the downgrade function won't work + ## unless we temporary remove importing `views` from `app/__init__.py` op.drop_column('setting', 'view') # delete added records in previous version