From 16a6de584a078b2648ce89f0f384884633a79a05 Mon Sep 17 00:00:00 2001
From: Marco Ciotola <848222@stud.unive.it>
Date: Sat, 25 Nov 2017 15:50:15 +0100
Subject: [PATCH] [DJ1.9] Remove warning of not declaring explicit app_label

Example:

RemovedInDjango19Warning: Model class helios.models.Voter doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.

(cherry picked from commit 693acef9e4c3b093d5bf2bc1655e6f53a6dd4007)
---
 helios/apps.py        |  5 +++++
 helios/models.py      | 26 ++++++++++++++++++++++----
 helios_auth/apps.py   |  5 +++++
 helios_auth/models.py |  3 ++-
 4 files changed, 34 insertions(+), 5 deletions(-)
 create mode 100644 helios/apps.py
 create mode 100644 helios_auth/apps.py

diff --git a/helios/apps.py b/helios/apps.py
new file mode 100644
index 0000000..9009743
--- /dev/null
+++ b/helios/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+class HeliosConfig(AppConfig):
+    name = 'helios'
+    verbose_name = "Helios"
diff --git a/helios/models.py b/helios/models.py
index 96b6654..a0d5c12 100644
--- a/helios/models.py
+++ b/helios/models.py
@@ -145,6 +145,9 @@ class Election(HeliosModel):
   # downloadable election info
   election_info_url = models.CharField(max_length=300, null=True)
 
+  class Meta:
+    app_label = 'helios'
+
   # metadata for the election
   @property
   def metadata(self):
@@ -649,7 +652,8 @@ class Election(HeliosModel):
       prettified_result.append({'question': q['short_name'], 'answers': pretty_question})
 
     return prettified_result
-    
+
+
 class ElectionLog(models.Model):
   """
   a log of events for an election
@@ -663,6 +667,9 @@ class ElectionLog(models.Model):
   log = models.CharField(max_length=500)
   at = models.DateTimeField(auto_now_add=True)
 
+  class Meta:
+    app_label = 'helios'
+
 ##
 ## UTF8 craziness for CSV
 ##
@@ -702,6 +709,9 @@ class VoterFile(models.Model):
   processing_finished_at = models.DateTimeField(auto_now_add=False, null=True)
   num_voters = models.IntegerField(null=True)
 
+  class Meta:
+    app_label = 'helios'
+
   def itervoters(self):
     if self.voter_file_content:
       if type(self.voter_file_content) == unicode:
@@ -779,7 +789,6 @@ class VoterFile(models.Model):
 
     return num_voters
 
-
     
 class Voter(HeliosModel):
   election = models.ForeignKey(Election)
@@ -813,6 +822,7 @@ class Voter(HeliosModel):
 
   class Meta:
     unique_together = (('election', 'voter_login_id'))
+    app_label = 'helios'
 
   def __init__(self, *args, **kwargs):
     super(Voter, self).__init__(*args, **kwargs)
@@ -1003,6 +1013,9 @@ class CastVote(HeliosModel):
   # auditing purposes, like too many votes from the same IP, if it isn't expected
   cast_ip = models.GenericIPAddressField(null=True)
 
+  class Meta:
+      app_label = 'helios'
+
   @property
   def datatype(self):
     return self.voter.datatype.replace('Voter', 'CastVote')
@@ -1091,6 +1104,9 @@ class AuditedBallot(models.Model):
   vote_hash = models.CharField(max_length=100)
   added_at = models.DateTimeField(auto_now_add=True)
 
+  class Meta:
+    app_label = 'helios'
+
   @classmethod
   def get(cls, election, vote_hash):
     return cls.objects.get(election = election, vote_hash = vote_hash)
@@ -1107,7 +1123,8 @@ class AuditedBallot(models.Model):
       query = query[:limit]
 
     return query
-    
+
+
 class Trustee(HeliosModel):
   election = models.ForeignKey(Election)
   
@@ -1140,7 +1157,8 @@ class Trustee(HeliosModel):
 
   class Meta:
     unique_together = (('election', 'email'))
-    
+    app_label = 'helios'
+
   def save(self, *args, **kwargs):
     """
     override this just to get a hook
diff --git a/helios_auth/apps.py b/helios_auth/apps.py
new file mode 100644
index 0000000..7d1472a
--- /dev/null
+++ b/helios_auth/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+class HeliosAuthConfig(AppConfig):
+    name = 'helios_auth'
+    verbose_name = "Helios Authentication"
diff --git a/helios_auth/models.py b/helios_auth/models.py
index b917995..d036037 100644
--- a/helios_auth/models.py
+++ b/helios_auth/models.py
@@ -35,7 +35,8 @@ class User(models.Model):
 
   class Meta:
     unique_together = (('user_type', 'user_id'),)
-    
+    app_label = 'helios_auth'
+
   @classmethod
   def _get_type_and_id(cls, user_type, user_id):
     return "%s:%s" % (user_type, user_id)    
-- 
GitLab