From d973dd48855f90821b701c848804eb76fd7560ea Mon Sep 17 00:00:00 2001
From: Marco Ciotola <848222@stud.unive.it>
Date: Mon, 4 Mar 2019 22:58:11 +0100
Subject: [PATCH] Upgrade Django to 1.9

---
 helios/test.py   | 25 ++++++++++++++-----------
 requirements.txt |  2 +-
 reset.sh         |  2 +-
 settings.py      |  6 +++---
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/helios/test.py b/helios/test.py
index 086f117..11fde1c 100644
--- a/helios/test.py
+++ b/helios/test.py
@@ -2,18 +2,21 @@
 Testing Helios Features
 """
 
-from helios.models import *
-from helios_auth.models import *
 import uuid
 
-def generate_voters(election, num_voters = 1000, start_with = 1):
-  # generate the user
-  for v_num in range(start_with, start_with + num_voters):
-    user = User(user_type='password', user_id='testuser%s' % v_num, name='Test User %s' % v_num)
-    user.put()
-    voter = Voter(uuid=str(uuid.uuid1()), election = election, voter_type=user.user_type, voter_id = user.user_id)
-    voter.put()
+from helios.models import Voter
+from helios_auth.models import User
+
+
+def generate_voters(election, num_voters=1000, start_with=1):
+    # generate the user
+    for v_num in range(start_with, start_with + num_voters):
+        user = User(user_type='password', user_id='testuser%s' % v_num, name='Test User %s' % v_num)
+        user.save()
+        voter = Voter(uuid=str(uuid.uuid1()), election=election, voter_type=user.user_type, voter_id=user.user_id)
+        voter.save()
+
 
 def delete_voters(election):
-  for v in Voter.get_by_election(election):
-    v.delete()
\ No newline at end of file
+    for v in Voter.get_by_election(election):
+        v.delete()
diff --git a/requirements.txt b/requirements.txt
index 0e0c0e8..1211f93 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-Django==1.8.19
+Django==1.9.13
 anyjson==0.3.3
 celery==3.1.25
 django-celery==3.2.2
diff --git a/reset.sh b/reset.sh
index 52141e1..8192723 100755
--- a/reset.sh
+++ b/reset.sh
@@ -2,6 +2,6 @@
 set -e  # Exit immediately if a command exits with a non-zero status.
 dropdb helios
 createdb helios
-python manage.py syncdb
+python manage.py makemigrations
 python manage.py migrate
 echo "from helios_auth.models import User; User.objects.create(user_type='google',user_id='ben@adida.net', info={'name':'Ben Adida'})" | python manage.py shell
\ No newline at end of file
diff --git a/settings.py b/settings.py
index 8d948ab..82d6d4d 100644
--- a/settings.py
+++ b/settings.py
@@ -47,7 +47,7 @@ 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
+    DATABASES['default']['CONN_MAX_AGE'] = '600'
 
     # require SSL
     DATABASES['default']['OPTIONS'] = {'sslmode': 'require'}
@@ -93,7 +93,7 @@ SECRET_KEY = get_from_env('SECRET_KEY', 'replaceme')
 ALLOWED_HOSTS = get_from_env('ALLOWED_HOSTS', 'localhost').split(",")
 
 # Secure Stuff
-if (get_from_env('SSL', '0') == '1'):
+if get_from_env('SSL', '0') == '1':
     SECURE_SSL_REDIRECT = True
     SESSION_COOKIE_SECURE = True
 
@@ -104,7 +104,7 @@ SESSION_COOKIE_HTTPONLY = True
 
 # let's go with one year because that's the way to do it now
 STS = False
-if (get_from_env('HSTS', '0') == '1'):
+if get_from_env('HSTS', '0') == '1':
     STS = True
     # we're using our own custom middleware now
     # SECURE_HSTS_SECONDS = 31536000
-- 
GitLab