app/soc/views/models/program.py
changeset 1855 8c76c32a2392
parent 1852 ea2e23e5b7a1
child 1857 febcaeb4234b
--- a/app/soc/views/models/program.py	Sat Mar 14 19:45:52 2009 +0000
+++ b/app/soc/views/models/program.py	Sat Mar 14 19:46:20 2009 +0000
@@ -198,7 +198,7 @@
       locked_slots = dicts.groupDictBy(from_json, 'locked', 'slots')
       adjusted_slots = dicts.groupDictBy(from_json, 'adjustment')
 
-    orgs = [i.link_id for i in organizations]
+    orgs = {}
     applications = {}
     mentors = {}
 
@@ -207,6 +207,7 @@
           'org': org,
           'status': ['new', 'pending']
           }
+      orgs[org.link_id] = org
       query = student_proposal_logic.logic.getQueryForFields(filter=filter)
       proposals = student_proposal_logic.logic.getAll(query)
       applications[org.link_id] = len(proposals)
@@ -217,7 +218,7 @@
     min_slots_per_org = 2
     iterative = False
 
-    allocator = allocations.Allocator(orgs, applications, mentors,
+    allocator = allocations.Allocator(orgs.keys(), applications, mentors,
                                       slots, max_slots_per_org,
                                       min_slots_per_org, iterative)
 
@@ -230,8 +231,8 @@
       data.append({
           'link_id': link_id,
           'slots': count,
-          'locked': org['locked'] if 'locked' in org else 0,
-          'adjustment': org['adjustment'] if 'adjustment' in org else 0,
+          'locked': locked_slots.get(link_id, 0),
+          'adjustment': adjusted_slots.get(link_id, 0),
           })
 
     return self.json(request, data)