diff --git a/SciPost_v1/settings/base.py b/SciPost_v1/settings/base.py index 8b0c8de82ac6e42c417b7c69e4bfc05c74302037..081cd3c2e480baa6e2c353c96dafdb2e415b8201 100644 --- a/SciPost_v1/settings/base.py +++ b/SciPost_v1/settings/base.py @@ -209,7 +209,13 @@ DATABASES = { 'PORT': '5432', } } - +MONGO_DATABASE = { + 'database': 'scipost', + 'host': 'localhost', + 'user': '', + 'password': '', + 'port': '27017', +} # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ diff --git a/SciPost_v1/settings/staging_release.py b/SciPost_v1/settings/staging_release.py index bef469d83c25b8e9418898747d2057fa002aa0fd..28c689878b7aa3fc0969ea1d0e6b47a711eb9915 100644 --- a/SciPost_v1/settings/staging_release.py +++ b/SciPost_v1/settings/staging_release.py @@ -23,3 +23,7 @@ WEBPACK_LOADER['DEFAULT']['BUNDLE_DIR_NAME'] = '/home/jdewit/webapps/scipost_sta # Logging LOGGING['handlers']['scipost_file_arxiv']['filename'] = '/home/jdewit/webapps/scipost/logs/arxiv.log' LOGGING['handlers']['scipost_file_doi']['filename'] = '/home/jdewit/webapps/scipost/logs/doi.log' + +MONGO_DATABASE['user'] = get_secret('MONGO_DB_USER') +MONGO_DATABASE['password'] = get_secret('MONGO_DB_PASSWORD') +MONGO_DATABASE['port'] = get_secret("MONGO_DB_PORT") diff --git a/metacore/models.py b/metacore/models.py index d9dde46762f26e63da484aea71d4dc9a1f23d083..7861cc09d4f1c6489dabb8bc779f406eb797eb46 100644 --- a/metacore/models.py +++ b/metacore/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.conf import settings + from mongoengine import connect, DynamicDocument, ListField, StringField,\ DynamicField, URLField, DateTimeField @@ -7,7 +9,12 @@ from .managers import CitableQuerySet # Make the connection to MongoDB - this could be put in settings.py as well # It uses default settings for the mongo server -connect('scipost') +connect(settings.MONGO_DATABASE['database'], + host=settings.MONGO_DATABASE['host'], + user=settings.MONGO_DATABASE['user'], + password=settings.MONGO_DATABASE['password'] + port=settings.MONGO_DATABASE['port']) + class Citable(DynamicDocument): """ @@ -60,4 +67,3 @@ class CitableWithDOI(Citable): def times_cited(self): return CitableWithDOI.objects.cited_by(self.doi).count() -