"Unused slots" column may show negative numbers.
The meaning, which was dicussed with a program administrator, is that the organization tries to use more slots than it is actually allocated.
Also, fields for which value is zero are not displayed in red.
diff --git a/app/soc/modules/gsoc/views/slot_allocation.py b/app/soc/modules/gsoc/views/slot_allocation.py
index 94157ab..36ee2a0 100644
--- a/app/soc/modules/gsoc/views/slot_allocation.py
+++ b/app/soc/modules/gsoc/views/slot_allocation.py
@@ -65,8 +65,7 @@
timeline = db.get(entities[0].program.to_old_key()).timeline
for entity in entities:
used_slots = proposal_logic.getUsedSlots(entity.key, timeline)
- org_slots_unused[entity.key] = max(
- entity.slot_allocation - used_slots, 0)
+ org_slots_unused[entity.key] = entity.slot_allocation - used_slots
return ([org_slots_unused], {})
@@ -99,10 +98,15 @@
list_config.setColumnEditable('slot_allocation', True)
list_config.setColumnSummary('slot_allocation', 'sum', '<b>Total: {0}</b>')
- list_config.addHtmlColumn(
- 'slots_unused', 'Unused slots',
- lambda ent, s, *args: ('<strong><font color="red">%s</font></strong>'
- % (s[ent.key])))
+ def getUnusedSlots(entity, cached_data, *args):
+ """Helper function to get value for 'Unused slots' column."""
+ unused_slots = cached_data[entity.key]
+ return (
+ str(unused_slots)
+ if unused_slots == 0
+ else '<strong><font color="red">%s</font></strong>' % unused_slots)
+
+ list_config.addHtmlColumn('slots_unused', 'Unused slots', getUnusedSlots)
# TODO(daniel): add note to organization model?
#list_config.addSimpleColumn('note', 'Note')