From b588cf2061c0bbf738d2d7d5ad2cdadaeb5e08c0 Mon Sep 17 00:00:00 2001
From: Marco Ciotola <848222@stud.unive.it>
Date: Tue, 3 Mar 2020 16:22:24 +0100
Subject: [PATCH] [db] db variables in settings and dj_database_url/psycopg2
 upgrades

---
 requirements.txt | 12 ++++++++----
 settings.py      | 10 ++++------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index 05e48c4..da11204 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,16 +1,17 @@
 Django==1.11.28
+
 celery==4.2.1
 django-picklefield==1.1.0
+
+dj_database_url==0.5.0
+psycopg2==2.8.4
+
 html5lib==0.999
-psycopg2==2.8.3
 python-dateutil>=1.5
 python3-openid==3.0.10
 gunicorn==19.9
 requests==2.21.0
 unicodecsv==0.14.1
-dj_database_url==0.3.0
-django_webtest>=1.9
-webtest==2.0.18
 bleach==3.1.1
 boto==2.49.0
 django-ses==0.8.10
@@ -18,3 +19,6 @@ py3-validate-email==0.1.11
 oauth2client==4.1.3
 rollbar==0.12.1
 pycryptodome==3.8.2
+
+django_webtest>=1.9
+webtest==2.0.18
diff --git a/settings.py b/settings.py
index 78a27e3..f47b898 100644
--- a/settings.py
+++ b/settings.py
@@ -38,19 +38,17 @@ SHOW_USER_INFO = (get_from_env('SHOW_USER_INFO', '1') == '1')
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.postgresql_psycopg2',
-        'NAME': 'helios'
+        'NAME': 'helios',
+        'CONN_MAX_AGE': 600,
     },
 }
 
 # override if we have an env variable
 if get_from_env('DATABASE_URL', None):
     import dj_database_url
-    DATABASES['default'] =  dj_database_url.config()
-    DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
-    DATABASES['default']['CONN_MAX_AGE'] = '600'
 
-    # require SSL
-    DATABASES['default']['OPTIONS'] = {'sslmode': 'require'}
+    DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
+    DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
 
 # Local time zone for this installation. Choices can be found here:
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-- 
GitLab