Changement du refresh handler, soft reset d'ajouter sur beaucoup de formulaire de modification
CI - Security, Lint & Tests / validate (push) Failing after 1m3s
CI - Security, Lint & Tests / validate (push) Failing after 1m3s
This commit is contained in:
+17
-12
@@ -3,7 +3,7 @@
|
||||
Uses polymorphic isinstance checks instead of role-string comparisons.
|
||||
"""
|
||||
|
||||
from flask import Blueprint, flash, jsonify, redirect, render_template, request, url_for
|
||||
from flask import Blueprint, flash, jsonify, render_template, request, url_for
|
||||
from flask_babel import gettext as _
|
||||
from flask_login import current_user, login_required
|
||||
from marshmallow import ValidationError
|
||||
@@ -13,6 +13,7 @@ from app.extensions import db
|
||||
from app.forms import flash_validation_errors, form_payload
|
||||
from app.models import (
|
||||
Admin,
|
||||
AppSettings,
|
||||
Coach,
|
||||
Manager,
|
||||
OrgTeam,
|
||||
@@ -20,10 +21,10 @@ from app.models import (
|
||||
TeamMatch,
|
||||
TeamMatchParticipant,
|
||||
TeamPlayer,
|
||||
AppSettings,
|
||||
)
|
||||
from app.pagination import paginate
|
||||
from app.permissions import can_manage_org_team, coach_org_teams, visible_org_teams
|
||||
from app.responders import respond_after_change
|
||||
from app.routes.matches import default_end_time
|
||||
from app.services.scheduling import notify_participants, zip_participants
|
||||
from app.time_utils import utc_now_naive
|
||||
@@ -121,12 +122,14 @@ def create_match(team_id):
|
||||
"""Create a new regular-season team match."""
|
||||
team = db.get_or_404(OrgTeam, team_id)
|
||||
if season_locked():
|
||||
flash('The regular season is not active. Begin a season before scheduling matches.', 'warning')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
flash(
|
||||
'The regular season is not active. Begin a season before scheduling matches.', 'warning'
|
||||
)
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
if not can_manage_team_match(team):
|
||||
flash(_('You do not have permission to schedule matches for this team.'), 'danger')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
team_players = TeamPlayer.query.filter_by(org_team_id=team_id).all()
|
||||
prefill_date = request.args.get('date', '')
|
||||
@@ -219,7 +222,7 @@ def create_match(team_id):
|
||||
flash(
|
||||
_('Team match "%(title)s" scheduled successfully!', title=team_match.title), 'success'
|
||||
)
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
return render_template('pages/team_match_form.html', team=team, team_players=team_players)
|
||||
|
||||
@@ -233,7 +236,7 @@ def edit_match(match_id):
|
||||
|
||||
if not can_manage_team_match(team):
|
||||
flash(_('You do not have permission to edit this match.'), 'danger')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
if request.method == 'POST':
|
||||
# The three date and time fields used to be checked one at a time,
|
||||
@@ -263,7 +266,7 @@ def edit_match(match_id):
|
||||
|
||||
db.session.commit()
|
||||
flash(_('Match updated successfully!'), 'success')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
return render_template(
|
||||
'pages/team_match_form.html', match=team_match, team=team, team_players=[]
|
||||
@@ -277,17 +280,19 @@ def delete_match(match_id):
|
||||
team_match = db.get_or_404(TeamMatch, match_id)
|
||||
team = team_match.org_team
|
||||
if season_locked():
|
||||
flash('The regular season is not active. Begin a season before deleting matches.', 'warning')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
flash(
|
||||
'The regular season is not active. Begin a season before deleting matches.', 'warning'
|
||||
)
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
if not can_manage_team_match(team):
|
||||
flash(_('You do not have permission to delete this match.'), 'danger')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
db.session.delete(team_match)
|
||||
db.session.commit()
|
||||
flash(_('Match deleted successfully.'), 'success')
|
||||
return redirect(url_for('team_matches.list_matches'))
|
||||
return respond_after_change(url_for('team_matches.list_matches'))
|
||||
|
||||
|
||||
@team_matches_bp.route('/api/manageable-teams')
|
||||
|
||||
Reference in New Issue
Block a user