diff --git a/app/email.py b/app/email.py index 1e3fb3ab..072b7bc3 100644 --- a/app/email.py +++ b/app/email.py @@ -10,11 +10,7 @@ def send_async_email(app, msg): def send_email(to, subject, template, **kwargs): - subject = '{} {}'.format(current_app.config['OPAQUE_MAIL_SUBJECT_PREFIX'], - subject) - msg = Message(subject, - sender=current_app.config['OPAQUE_MAIL_SENDER'], - recipients=[to]) + msg = Message('[Opaque] {}'.format(subject), recipients=[to]) msg.body = render_template(template + '.txt.j2', **kwargs) msg.html = render_template(template + '.html.j2', **kwargs) thr = Thread(target=send_async_email, diff --git a/app/main/views.py b/app/main/views.py index efb2b0bd..9acc9061 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -21,7 +21,7 @@ def corpus(corpus_id): print('Corpus not found.') 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), 'corpora', str(corpus.id)) @@ -44,7 +44,7 @@ def corpus_download(corpus_id): if not file or not corpus: print('File not found.') 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), 'corpora', str(corpus.id)) @@ -66,7 +66,7 @@ def dashboard(): db.session.add(corpus) db.session.commit() - dir = os.path.join(app.config['OPAQUE_STORAGE'], + dir = os.path.join(app.config['OPAQUE_STORAGE_DIRECTORY'], str(corpus.user_id), 'corpora', str(corpus.id)) @@ -96,7 +96,7 @@ def job(job_id): print('Job not found.') 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), 'jobs', str(job.id)) @@ -130,7 +130,7 @@ def job_download(job_id): if not file or not job: print('File not found.') 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), 'jobs', str(job.id)) diff --git a/config.py b/config.py index 96aaa6d1..836cdcfe 100644 --- a/config.py +++ b/config.py @@ -1,47 +1,48 @@ import os -basedir = os.path.abspath(os.path.dirname(__file__)) - - 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_PORT = int(os.environ.get('MAIL_PORT')) MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS').lower() == 'true' MAIL_USERNAME = os.environ.get('MAIL_USERNAME') MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') - OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN') - OPAQUE_STORAGE = os.environ.get('OPAQUE_STORAGE') - OPAQUE_MAIL_SUBJECT_PREFIX = '[Opaque]' - OPAQUE_MAIL_SENDER = 'Opaque' - SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard to guess string' + MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER') + + ''' ### Flask-SQLAlchemy ### ''' SQLALCHEMY_TRACK_MODIFICATIONS = False + ''' ### Opaque ### ''' + OPAQUE_ADMIN = os.environ.get('OPAQUE_ADMIN') + OPAQUE_STORAGE_DIRECTORY = os.environ.get('OPAQUE_STORAGE_DIRECTORY') + @staticmethod def init_app(app): pass class DevelopmentConfig(Config): + ''' ### Flask ### ''' 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 = { 'development': DevelopmentConfig, - 'testing': TestingConfig, - # 'production': ProductionConfig, - + 'production': ProductionConfig, 'default': DevelopmentConfig }