From d2875c2144924427faed6a7ea824c69422ad94a4 Mon Sep 17 00:00:00 2001
From: Ben Adida <ben@adida.net>
Date: Sun, 27 May 2012 21:47:44 -0700
Subject: [PATCH] more robustness for eligibility category

---
 helios/models.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/helios/models.py b/helios/models.py
index b30b711..c3a5637 100644
--- a/helios/models.py
+++ b/helios/models.py
@@ -251,7 +251,12 @@ class Election(HeliosModel):
     if not self.eligibility:
       return []
 
-    return [constraint['constraint'] for constraint in self.eligibility if constraint['auth_system'] == user_type][0]
+    # constraints that are relevant
+    relevant_constraints = [constraint['constraint'] for constraint in self.eligibility if constraint['auth_system'] == user_type]
+    if len(relevant_constraints) > 0:
+      return relevant_constraints[0]
+    else:
+      return []
 
   def eligibility_category_id(self, user_type):
     "when eligibility is by category, this returns the category_id"
-- 
GitLab