Skip to content
Snippets Groups Projects
Commit 40809d9c authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Change setting names.

parent a05e37dd
No related branches found
No related tags found
No related merge requests found
...@@ -10,11 +10,7 @@ def send_async_email(app, msg): ...@@ -10,11 +10,7 @@ def send_async_email(app, msg):
def send_email(to, subject, template, **kwargs): def send_email(to, subject, template, **kwargs):
subject = '{} {}'.format(current_app.config['OPAQUE_MAIL_SUBJECT_PREFIX'], msg = Message('[Opaque] {}'.format(subject), recipients=[to])
subject)
msg = Message(subject,
sender=current_app.config['OPAQUE_MAIL_SENDER'],
recipients=[to])
msg.body = render_template(template + '.txt.j2', **kwargs) msg.body = render_template(template + '.txt.j2', **kwargs)
msg.html = render_template(template + '.html.j2', **kwargs) msg.html = render_template(template + '.html.j2', **kwargs)
thr = Thread(target=send_async_email, thr = Thread(target=send_async_email,
......
...@@ -21,7 +21,7 @@ def corpus(corpus_id): ...@@ -21,7 +21,7 @@ def corpus(corpus_id):
print('Corpus not found.') print('Corpus not found.')
abort(404) abort(404)
dir = os.path.join(current_app.config['OPAQUE_STORAGE'], dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(current_user.id), str(current_user.id),
'corpora', 'corpora',
str(corpus.id)) str(corpus.id))
...@@ -44,7 +44,7 @@ def corpus_download(corpus_id): ...@@ -44,7 +44,7 @@ def corpus_download(corpus_id):
if not file or not corpus: if not file or not corpus:
print('File not found.') print('File not found.')
abort(404) abort(404)
dir = os.path.join(current_app.config['OPAQUE_STORAGE'], dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(current_user.id), str(current_user.id),
'corpora', 'corpora',
str(corpus.id)) str(corpus.id))
...@@ -66,7 +66,7 @@ def dashboard(): ...@@ -66,7 +66,7 @@ def dashboard():
db.session.add(corpus) db.session.add(corpus)
db.session.commit() db.session.commit()
dir = os.path.join(app.config['OPAQUE_STORAGE'], dir = os.path.join(app.config['OPAQUE_STORAGE_DIRECTORY'],
str(corpus.user_id), str(corpus.user_id),
'corpora', 'corpora',
str(corpus.id)) str(corpus.id))
...@@ -96,7 +96,7 @@ def job(job_id): ...@@ -96,7 +96,7 @@ def job(job_id):
print('Job not found.') print('Job not found.')
abort(404) abort(404)
dir = os.path.join(current_app.config['OPAQUE_STORAGE'], dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(current_user.id), str(current_user.id),
'jobs', 'jobs',
str(job.id)) str(job.id))
...@@ -130,7 +130,7 @@ def job_download(job_id): ...@@ -130,7 +130,7 @@ def job_download(job_id):
if not file or not job: if not file or not job:
print('File not found.') print('File not found.')
abort(404) abort(404)
dir = os.path.join(current_app.config['OPAQUE_STORAGE'], dir = os.path.join(current_app.config['OPAQUE_STORAGE_DIRECTORY'],
str(current_user.id), str(current_user.id),
'jobs', 'jobs',
str(job.id)) str(job.id))
......
import os import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config: class Config:
''' ### Flask ### '''
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
''' ### Flask-Mail ### '''
MAIL_SERVER = os.environ.get('MAIL_SERVER') MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = int(os.environ.get('MAIL_PORT')) MAIL_PORT = int(os.environ.get('MAIL_PORT'))
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS').lower() == 'true' MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS').lower() == 'true'
MAIL_USERNAME = os.environ.get('MAIL_USERNAME') MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN') MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')
OPAQUE_STORAGE = os.environ.get('OPAQUE_STORAGE')
OPAQUE_MAIL_SUBJECT_PREFIX = '[Opaque]' ''' ### Flask-SQLAlchemy ### '''
OPAQUE_MAIL_SENDER = 'Opaque'
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string'
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
''' ### Opaque ### '''
OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN')
OPAQUE_STORAGE_DIRECTORY = os.environ.get('OPAQUE_STORAGE_DIRECTORY')
@staticmethod @staticmethod
def init_app(app): def init_app(app):
pass pass
class DevelopmentConfig(Config): class DevelopmentConfig(Config):
''' ### Flask ### '''
DEBUG = True DEBUG = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir,
'data_dev.sqlite')
''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(
os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data_dev.sqlite')
)
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
'sqlite://'
WTF_CSRF_ENABLED = False
class ProductionConfig(Config):
# class ProductionConfig(Config): ''' ### Flask-SQLAlchemy ### '''
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
config = { config = {
'development': DevelopmentConfig, 'development': DevelopmentConfig,
'testing': TestingConfig, 'production': ProductionConfig,
# 'production': ProductionConfig,
'default': DevelopmentConfig 'default': DevelopmentConfig
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment