示例#1
0
 def setUp(self):
     self.app = Flask(__name__)
     self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
     self.app.config['USER_LIST'] = ['Test Admin']
     db.init_app(self.app)
     d = TempDirectory()
     d.makedir('dataset')
     d.write('dataset/files/testfile.jpg', 'abc')
     d.write('dataset/testfile2.jpg', 'abc')
     self.directory = d
     self.app.config['DATASET_ROOT'] = d.path
     with self.app.app_context(), TempDirectory() as d:
         db.create_all()
         lib.models.buildDB()
         dataset = lib.models.Datasets()
         dataset.name = 'Test'
         dataset.path = "dataset"
         db.session.add(dataset)
         db.session.commit()
示例#2
0
 def setUp(self):
     self.app = Flask(__name__)
     self.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
     self.app.config['USER_LIST'] = ['Test Admin']
     db.init_app(self.app)
     d = TempDirectory()
     d.makedir('dataset')
     d.write('dataset/files/testfile.jpg', 'abc')
     d.write('dataset/testfile2.jpg', 'abc')
     self.directory = d
     self.app.config['DATASET_ROOT'] = d.path
     with self.app.app_context(), TempDirectory() as d:
         db.create_all()
         lib.models.buildDB()
         dataset = lib.models.Datasets()
         dataset.name = 'Test'
         dataset.path = "dataset"
         db.session.add(dataset)
         db.session.commit()
示例#3
0
 def setUp(self):
     data.app.config['TESTING'] = True
     data.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
     data.app.config['USER_LIST'] = ['Test Admin']
     db.init_app(data.app)
     d = TempDirectory()
     d.makedir('dataset')
     d.write('dataset/files/testfile.jpg', 'abc')
     d.write('dataset/testfile2.jpg', 'abc')
     self.directory = d
     data.app.config['DATASET_ROOT'] = d.path
     with data.app.app_context(), TempDirectory() as d:
         db.create_all()
         lib.models.buildDB()
         license = lib.models.License.query.first()
         provider = lib.models.Provider.query.first()
         dataset = lib.models.Datasets()
         dataset.name = 'Test'
         dataset.license = [license]
         dataset.provider = [provider]
         dataset.path = "dataset"
         db.session.add(dataset)
         db.session.commit()
     self.app = data.app.test_client()
示例#4
0
from werkzeug.contrib.cache import SimpleCache
from rdflib import Graph
from lib import views
from lib import models
from lib import logon
from lib.dbShared import db
from StringIO import StringIO

MT_RDF_XML = 'application/rdf+xml'
APP_BASE_URI = 'https://data.kb.se/'

cache = SimpleCache()
app = Flask(__name__)
admin = Admin(app, base_template='admin/base_admin.html')
app.config.from_pyfile('settings.py')
db.init_app(app)
curDir = path.dirname(path.realpath(__file__))
secretsFile = path.join(curDir, 'secrets')
with open(secretsFile, 'r') as sfile:
    app.secret_key = sfile.read()
    salt = app.secret_key

with app.app_context():
    dirIndex = directory_indexer()
index_dir = dirIndex.index_dir


class Models(ModelView):
    def is_accessible(self):
        if session.get('username', None) and session.get('is_admin', 'False') == 'True':
            return True
示例#5
0
from werkzeug.contrib.cache import SimpleCache
from rdflib import Graph
from lib import views
from lib import models
from lib import logon
from lib.dbShared import db
from StringIO import StringIO

MT_RDF_XML = 'application/rdf+xml'
APP_BASE_URI = 'https://data.kb.se/'

cache = SimpleCache()
app = Flask(__name__)
admin = Admin(app, base_template='admin/base_admin.html')
app.config.from_pyfile('settings.py')
db.init_app(app)
curDir = path.dirname(path.realpath(__file__))
secretsFile = path.join(curDir, 'secrets')
with open(secretsFile, 'r') as sfile:
    app.secret_key = sfile.read()
    salt = app.secret_key

with app.app_context():
    dirIndex = directory_indexer()
index_dir = dirIndex.index_dir


class Models(ModelView):
    def is_accessible(self):
        if session.get('username', None) and session.get('is_admin',
                                                         'False') == 'True':