# HG changeset patch # User Lennard de Rijk # Date 1236534062 0 # Node ID 564f3adf4acf4010c4d723448b2925645c6c629e # Parent 255117ccd6a019a7289faa2720c8078ddf8ee5cc Students who withdraw their proposal will now be removed from the ranker. And therefore don't influence the ranking of other proposals anymore. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 255117ccd6a0 -r 564f3adf4acf app/soc/logic/models/student_proposal.py --- a/app/soc/logic/models/student_proposal.py Sun Mar 08 17:19:25 2009 +0000 +++ b/app/soc/logic/models/student_proposal.py Sun Mar 08 17:41:02 2009 +0000 @@ -58,7 +58,10 @@ super(Logic, self)._onCreate(entity) def _updateField(self, entity, entity_properties, name): - """Update the ranker if the score changes and keep the score within bounds. + """Called when the fields of the student_proposal are updated. + + - Update the ranker if the score changes and keep the score within bounds + - Remove the entity from the ranker when the status changes to invalid or rejected """ value = entity_properties[name] @@ -78,6 +81,19 @@ ranker = ranker_root_logic.getRootFromEntity(ranker_root) ranker.SetScore(entity.key().name(), [value]) + if name == 'status': + + if value in ['invalid', 'rejected'] and entity.status != value: + # the proposal is going into invalid or rejected state + # remove the score from the ranker + fields = {'link_id': student_proposal.DEF_RANKER_NAME, + 'scope': entity.org} + + ranker_root = ranker_root_logic.getForFields(fields, unique=True) + ranker = ranker_root_logic.getRootFromEntity(ranker_root) + + # entries in the ranker can be removed by setting the score to None + ranker.SetScore(entity.key().name(), None) return super(Logic, self)._updateField(entity, entity_properties, name)