Update .travis.yml to use mysql for db. Fix RECORDS_ALLOW_EDIT config key

This commit is contained in:
Khanh Ngo 2018-08-22 17:57:12 +07:00
parent b338b64795
commit 66e9be8c7a
No known key found for this signature in database
GPG Key ID: B9AE3BAF6D5A7B22
4 changed files with 14 additions and 10 deletions

View File

@ -2,10 +2,12 @@ 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 yarn'
- 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 yarn
- mysql -e 'CREATE DATABASE pda';
- mysql -e "GRANT ALL PRIVILEGES ON pda.* to pda@'%' IDENTIFIED BY 'changeme'";
install:
- pip install -r requirements.txt
before_script:
@ -18,3 +20,5 @@ script:
- sh run_travis.sh
cache:
yarn: true
services:
- mysql

View File

@ -40,5 +40,5 @@ from app import models
try:
from app import views
except OperationalError:
except:
logging.error("You have not initialized the DB yet or DB migration is running...")

View File

@ -1372,7 +1372,7 @@ class Record(object):
list_deleted_records = [x for x in list_current_records if x not in list_new_records]
# convert back to list of hash
deleted_records = [x for x in current_records if [x['name'],x['type']] in list_deleted_records and (x['type'] in app.config['RECORDS_ALLOW_EDIT'] and x['type'] != 'SOA')]
deleted_records = [x for x in current_records if [x['name'],x['type']] in list_deleted_records and (x['type'] in Setting().get_records_allow_to_edit() and x['type'] != 'SOA')]
# return a tuple
return deleted_records, new_records
@ -1612,13 +1612,13 @@ class Record(object):
"""
Check if record is allowed to edit
"""
return self.type in app.config['RECORDS_ALLOW_EDIT']
return self.type in Setting().get_records_allow_to_edit()
def is_allowed_delete(self):
"""
Check if record is allowed to removed
"""
return (self.type in app.config['RECORDS_ALLOW_EDIT'] and self.type != 'SOA')
return (self.type in Setting().get_records_allow_to_edit() and self.type != 'SOA')
def exists(self, domain):
"""

View File

@ -26,10 +26,10 @@ SQLA_DB_NAME = 'pda'
SQLALCHEMY_TRACK_MODIFICATIONS = True
# DATBASE - MySQL
#SQLALCHEMY_DATABASE_URI = 'mysql://'+SQLA_DB_USER+':'+SQLA_DB_PASSWORD+'@'+SQLA_DB_HOST+'/'+SQLA_DB_NAME
SQLALCHEMY_DATABASE_URI = 'mysql://'+SQLA_DB_USER+':'+SQLA_DB_PASSWORD+'@'+SQLA_DB_HOST+'/'+SQLA_DB_NAME
# DATABSE - SQLite
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'pdns.db')
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'pdns.db')
# SAML Authnetication
SAML_ENABLED = False