From 49e09eb5f498dec4328f16e34927b5bdc6b39951 Mon Sep 17 00:00:00 2001
From: Ben Adida <ben@adida.net>
Date: Tue, 7 Jun 2011 22:29:03 -0700
Subject: [PATCH] fixed bug on eligibility

---
 helios/models.py | 7 +++++--
 helios/tests.py  | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/helios/models.py b/helios/models.py
index 967709c..77921cc 100644
--- a/helios/models.py
+++ b/helios/models.py
@@ -266,8 +266,11 @@ class Election(HeliosModel):
       return_val = "<ul>"
       
       for constraint in self.eligibility:
-        for one_constraint in constraint['constraint']:
-          return_val += "<li>%s</li>" % AUTH_SYSTEMS[constraint['auth_system']].pretty_eligibility(one_constraint)
+        if constraint.has_key('constraint'):
+          for one_constraint in constraint['constraint']:
+            return_val += "<li>%s</li>" % AUTH_SYSTEMS[constraint['auth_system']].pretty_eligibility(one_constraint)
+        else:
+          return_val += "<li> any %s user</li>" % constraint['auth_system']
 
       return_val += "</ul>"
 
diff --git a/helios/tests.py b/helios/tests.py
index aa94b77..1523ae3 100644
--- a/helios/tests.py
+++ b/helios/tests.py
@@ -148,6 +148,9 @@ class ElectionModelTests(TestCase):
         # without openreg, and now true
         self.assertTrue(self.election.user_eligible_p(self.user))
 
+        # try getting pretty eligibility, make sure it doesn't throw an exception
+        assert self.user.user_type in self.election.pretty_eligibility
+
     def test_facebook_eligibility(self):
         self.election.eligibility = [{'auth_system': 'facebook', 'constraint':[{'group': {'id': '123', 'name':'Fake Group'}}]}]
 
-- 
GitLab