This commit is contained in:
+1
-1
@@ -211,7 +211,7 @@ def restore_backup(backup_id):
|
||||
|
||||
# Create a safety backup of the current state before restoring.
|
||||
try:
|
||||
safety = _create_backup_record(
|
||||
_create_backup_record(
|
||||
backup_type='pre_restore',
|
||||
notes='Automatic safety backup before restoring ' + record.filename,
|
||||
)
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -649,14 +649,14 @@ def edit_match(match_id):
|
||||
|
||||
# Purge Discord pending entries for participants that no longer exist.
|
||||
if removed_ids:
|
||||
from app.discord_bot import purge_pending_for_participants
|
||||
from app.discord import purge_pending_for_participants
|
||||
|
||||
purge_pending_for_participants(removed_ids)
|
||||
|
||||
# Decide whether and what to notify.
|
||||
if time_changed:
|
||||
# All current participants get the "modified" message.
|
||||
all_current = list(zip(notified_player_ids, notified_participant_ids))
|
||||
all_current = list(zip(notified_player_ids, notified_participant_ids, strict=True))
|
||||
notify_participants(
|
||||
title=match.title,
|
||||
date=match.date,
|
||||
@@ -671,7 +671,7 @@ def edit_match(match_id):
|
||||
new_player_ids = desired - set(existing.keys())
|
||||
new_pairs = [
|
||||
(pid, nid)
|
||||
for pid, nid in zip(notified_player_ids, notified_participant_ids)
|
||||
for pid, nid in zip(notified_player_ids, notified_participant_ids, strict=True)
|
||||
if pid in new_player_ids
|
||||
]
|
||||
notify_participants(
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
import os
|
||||
import uuid
|
||||
|
||||
from flask import flash, redirect, render_template, request, send_file, url_for
|
||||
from flask import flash, render_template, request, send_file, url_for
|
||||
from flask_babel import gettext as _
|
||||
from flask_login import current_user, login_required
|
||||
from marshmallow import ValidationError
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
from app.extensions import db
|
||||
from app.responders import respond_after_change
|
||||
from app.models import Admin, Coach, Contract, Manager, Player, User
|
||||
from app.models.admin_settings import AppSettings
|
||||
from app.permissions import can_manage_player_contract, coach_player_ids
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.users._shared import (
|
||||
ALLOWED_CONTRACT_EXTENSIONS,
|
||||
ALLOWED_SIGNED_EXTENSIONS,
|
||||
|
||||
@@ -10,7 +10,6 @@ from flask_login import current_user, login_required
|
||||
from marshmallow import ValidationError
|
||||
|
||||
from app.extensions import db
|
||||
from app.responders import respond_after_change
|
||||
from app.forms import flash_validation_errors, form_payload
|
||||
from app.models import (
|
||||
Coach,
|
||||
@@ -32,6 +31,7 @@ from app.permissions import (
|
||||
coach_player_ids,
|
||||
coach_tryouts,
|
||||
)
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.users.blueprint import users_bp
|
||||
from app.validators import NoteContentSchema, PersonalNoteSchema
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ from flask_login import current_user, login_required
|
||||
from marshmallow import ValidationError
|
||||
|
||||
from app.extensions import db
|
||||
from app.responders import respond_after_change
|
||||
from app.forms import flash_validation_errors, form_payload
|
||||
from app.models import Coach, CoachAvailability, OneOnOneRequest, PersonalNote, Player, TeamNote
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.users.blueprint import users_bp
|
||||
from app.services.notifications import send_discord_notification
|
||||
from app.time_utils import utc_now_naive
|
||||
@@ -183,7 +183,7 @@ def accept_one_on_one(request_id):
|
||||
|
||||
# Notify player via Discord (same message as if approved through Discord reactions)
|
||||
if player and player.discord_user_id:
|
||||
from app.discord_bot import send_one_on_one_response
|
||||
from app.discord import send_one_on_one_response
|
||||
|
||||
send_one_on_one_response(
|
||||
player_discord_id=player.discord_user_id,
|
||||
@@ -242,7 +242,7 @@ def reject_one_on_one(request_id):
|
||||
|
||||
# Notify player via Discord (same message as if rejected through Discord reactions)
|
||||
if player and player.discord_user_id:
|
||||
from app.discord_bot import send_one_on_one_response
|
||||
from app.discord import send_one_on_one_response
|
||||
|
||||
send_one_on_one_response(
|
||||
player_discord_id=player.discord_user_id,
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
"""The signed-in user's own profile."""
|
||||
|
||||
from flask import flash, redirect, render_template, request, url_for
|
||||
from flask import flash, render_template, request, url_for
|
||||
from flask_babel import gettext as _
|
||||
from flask_login import current_user, login_required
|
||||
from marshmallow import ValidationError
|
||||
|
||||
from app.extensions import db, hash_password
|
||||
from app.responders import respond_after_change
|
||||
from app.logging_config import log_auth_event
|
||||
from app.models import (
|
||||
ESPORT_GAMES,
|
||||
@@ -17,6 +16,7 @@ from app.models import (
|
||||
Player,
|
||||
User,
|
||||
)
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.users._shared import (
|
||||
flash_validation_errors,
|
||||
form_payload,
|
||||
|
||||
Reference in New Issue
Block a user