diff --git a/helios/models.py b/helios/models.py index 967709c91868c09c0d4f50606e217c45d9d6c958..77921cc0f60b638a78244704a683e5c050350dca 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 aa94b774968c99b273c4270ad8c1214e04599e55..1523ae3e9719fb07a5f5d87461148fb07e14b2b7 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'}}]}]