Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean out Mongo unused settings #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,11 @@ django_environment_vars:
web_page_title: "Ona"
kpi_raven_frontend_env: ""
kpi_raven_backend_env: ""
kpi_enable_mongo_connection: false

# Mongo vars
kpi_mongo_db_host: "mongo"
kpi_mongo_db_port: 27017
kpi_mongo_db_name: "formhub"
kpi_mongo_db_user: ""
kpi_mongo_db_password: ""

This file was deleted.

15 changes: 10 additions & 5 deletions templates/kpi/settings.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,11 @@ KOBOCAT_DEFAULT_PERMISSION_CONTENT_TYPES = [
]

MONGO_DATABASE = {
'HOST': os.environ.get('KPI_MONGO_HOST', 'mongo'),
'PORT': int(os.environ.get('KPI_MONGO_PORT', 27017)),
'NAME': os.environ.get('KPI_MONGO_NAME', 'formhub'),
'USER': os.environ.get('KPI_MONGO_USER', ''),
'PASSWORD': os.environ.get('KPI_MONGO_PASS', '')
'HOST': '{{ kpi_mongo_db_host }}',
'PORT': '{{ kpi_mongo_db_port }}',
'NAME': '{{ kpi_mongo_db_name }}',
'USER': '{{ kpi_mongo_db_user }}',
'PASSWORD': '{{ kpi_mongo_db_password }}',
}

if MONGO_DATABASE.get('USER') and MONGO_DATABASE.get('PASSWORD'):
Expand All @@ -765,6 +765,11 @@ if MONGO_DATABASE.get('USER') and MONGO_DATABASE.get('PASSWORD'):
else:
MONGO_CONNECTION_URL = "mongodb://%(HOST)s:%(PORT)s" % MONGO_DATABASE

{% if kpi_enable_mongo_connection %}
MONGO_CONNECTION = MongoClient(
MONGO_CONNECTION_URL, j=True, tz_aware=True, connect=False)
MONGO_DB = MONGO_CONNECTION[MONGO_DATABASE['NAME']]
{% else %}
MONGO_CONNECTION = None
MONGO_DB = None
Comment on lines +773 to +774
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make the two values configurable via the vars with the default being None... Would make it easier in the future to utilize this functionality if the need arises

...
{% if enable_mongo_connection %}
MONGO_CONNECTION = MongoClient({{ mongo_connection_ url }}, .....
{% endif %}
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.
Made this change

{% endif %}