# HG changeset patch # User Lennard de Rijk # Date 1236121291 0 # Node ID 09bccdf6bdec9f5b6be25acc72d64cc1b705d89e # Parent 83e7b09ce9594892a836c70ad8ae6fafcda43ace Keep the score within the allowed bounds via student_proposal logic. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 83e7b09ce959 -r 09bccdf6bdec app/soc/logic/models/student_proposal.py --- a/app/soc/logic/models/student_proposal.py Tue Mar 03 22:52:11 2009 +0000 +++ b/app/soc/logic/models/student_proposal.py Tue Mar 03 23:01:31 2009 +0000 @@ -57,12 +57,19 @@ super(Logic, self)._onCreate(entity) def _updateField(self, entity, entity_properties, name): - """Update the ranker if the score changes + """Update the ranker if the score changes and keep the score within bounds. """ value = entity_properties[name] if name == 'score': + # keep the score within bounds + min_score, max_score = student_proposal.DEF_SCORE + + value = max(min_score, min(value, max_score-1)) + entity_properties[name] = value + + # update the ranker fields = {'link_id': student_proposal.DEF_RANKER_NAME, 'scope': entity.org} @@ -70,6 +77,7 @@ ranker = ranker_logic.logic.getRootFromEntity(ranker_root) ranker.SetScore(entity.key().name(), [value]) + return super(Logic, self)._updateField(entity, entity_properties, name)