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:
@@ -10,6 +10,7 @@ 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
|
||||
@@ -102,11 +103,11 @@ def upload_contract():
|
||||
"""Upload a contract for a player."""
|
||||
if not isinstance(current_user, (Admin, Manager, Coach)):
|
||||
flash(_('Only presidents, managers, and coaches can upload contracts.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
if document_uploads_locked():
|
||||
flash(_('Document uploads are currently disabled.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
players = manageable_players()
|
||||
|
||||
@@ -125,13 +126,13 @@ def upload_contract():
|
||||
|
||||
if not can_manage_player_contract(current_user, player_id):
|
||||
flash(_('You do not have permission to upload a contract for this player.'), 'danger')
|
||||
return redirect(url_for('users.upload_contract'))
|
||||
return respond_after_change(url_for('users.upload_contract'))
|
||||
|
||||
file = request.files.get('contract_file')
|
||||
error = pdf_upload_error(file, ALLOWED_CONTRACT_EXTENSIONS)
|
||||
if error:
|
||||
flash(error, 'danger')
|
||||
return redirect(url_for('users.upload_contract'))
|
||||
return respond_after_change(url_for('users.upload_contract'))
|
||||
|
||||
player = db.get_or_404(User, player_id)
|
||||
player_teams = player.get_org_teams()
|
||||
@@ -154,7 +155,7 @@ def upload_contract():
|
||||
flash(
|
||||
_('Contract storage is temporarily unavailable. Please try again later.'), 'danger'
|
||||
)
|
||||
return redirect(url_for('users.upload_contract'))
|
||||
return respond_after_change(url_for('users.upload_contract'))
|
||||
|
||||
contract = Contract(
|
||||
player_id=player_id,
|
||||
@@ -171,7 +172,7 @@ def upload_contract():
|
||||
_('Contract uploaded successfully for %(username)s!', username=player.username),
|
||||
'success',
|
||||
)
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
return render_template('pages/upload_contract.html', players=players)
|
||||
|
||||
@@ -183,17 +184,17 @@ def upload_signed_contract(contract_id):
|
||||
contract = db.get_or_404(Contract, contract_id)
|
||||
if not contract.can_upload_signed(current_user):
|
||||
flash(_('Only the player can upload their signed contract.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
if document_uploads_locked():
|
||||
flash(_('Document uploads are currently disabled.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
file = request.files.get('signed_file')
|
||||
error = pdf_upload_error(file, ALLOWED_SIGNED_EXTENSIONS)
|
||||
if error:
|
||||
flash(error, 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
signed_filename = f"signed_{contract.stored_filename}"
|
||||
# Legacy local records keep their signed copy beside the original. Drive
|
||||
@@ -208,7 +209,7 @@ def upload_signed_contract(contract_id):
|
||||
stored_signed_path = store_uploaded_document(file, signed_path)
|
||||
except GoogleDriveStorageError:
|
||||
flash(_('Contract storage is temporarily unavailable. Please try again later.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
contract.signed_filename = signed_filename
|
||||
contract.signed_file_path = stored_signed_path
|
||||
@@ -216,7 +217,7 @@ def upload_signed_contract(contract_id):
|
||||
contract.signed_at = utc_now_naive()
|
||||
db.session.commit()
|
||||
flash(_('Signed contract uploaded successfully!'), 'success')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
|
||||
|
||||
@users_bp.route('/contracts/<int:contract_id>/download')
|
||||
@@ -226,12 +227,12 @@ def download_contract(contract_id):
|
||||
contract = db.get_or_404(Contract, contract_id)
|
||||
if not contract.can_view(current_user):
|
||||
flash(_('You do not have permission to download this contract.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
try:
|
||||
document = open_document(contract.file_path)
|
||||
except GoogleDriveStorageError:
|
||||
flash(_('Contract storage is temporarily unavailable. Please try again later.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
return send_file(document, as_attachment=True, download_name=contract.original_filename)
|
||||
|
||||
|
||||
@@ -242,13 +243,13 @@ def download_signed_contract(contract_id):
|
||||
contract = db.get_or_404(Contract, contract_id)
|
||||
if not contract.can_view(current_user):
|
||||
flash(_('You do not have permission to download this contract.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
if not contract.signed_file_path:
|
||||
flash(_('No signed contract available.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
try:
|
||||
document = open_document(contract.signed_file_path)
|
||||
except GoogleDriveStorageError:
|
||||
flash(_('Contract storage is temporarily unavailable. Please try again later.'), 'danger')
|
||||
return redirect(url_for('users.list_contracts'))
|
||||
return respond_after_change(url_for('users.list_contracts'))
|
||||
return send_file(document, as_attachment=True, download_name=contract.signed_filename)
|
||||
|
||||
Reference in New Issue
Block a user