This commit is contained in:
@@ -29,6 +29,40 @@ from app.validators import EvaluationSchema
|
||||
evaluations_bp = Blueprint('evaluations', __name__, url_prefix='/evaluations')
|
||||
|
||||
|
||||
def validate_score(value):
|
||||
"""Convert a raw form value to an int 1..10, or None if blank/invalid.
|
||||
|
||||
Args:
|
||||
value: Raw value from request.form — a string, or None for a missing field.
|
||||
|
||||
Returns:
|
||||
int | None: Score 1-10, or None.
|
||||
"""
|
||||
if value is None or (isinstance(value, str) and value.strip() == ''):
|
||||
return None
|
||||
try:
|
||||
score = int(value)
|
||||
except (ValueError, TypeError):
|
||||
return None
|
||||
if score < 1 or score > 10:
|
||||
return None
|
||||
return score
|
||||
|
||||
|
||||
def _apply_evaluation(evaluation, scores, comments, position):
|
||||
"""Write scores, comments and recommended position onto an Evaluation row.
|
||||
|
||||
Args:
|
||||
evaluation: The Evaluation instance (new or existing).
|
||||
scores: Dict mapping criterion name to int or None.
|
||||
comments: Free-text comment string, or None.
|
||||
position: Recommended position string, or None.
|
||||
"""
|
||||
evaluation.apply_scores(scores)
|
||||
evaluation.comments = comments
|
||||
evaluation.position_recommendation = position
|
||||
|
||||
|
||||
def _users_by_id(user_ids):
|
||||
"""Load a set of users once for aggregate/list views."""
|
||||
wanted = {user_id for user_id in user_ids if user_id}
|
||||
|
||||
Reference in New Issue
Block a user