fix probleme avec dispos
This commit is contained in:
+13
-25
@@ -46,19 +46,6 @@ def api_events():
|
||||
tryouts = get_visible_tryouts_for_user()
|
||||
|
||||
for tryout in tryouts:
|
||||
events.append({
|
||||
'id': f'tryout_{tryout.id}',
|
||||
'title': tryout.title,
|
||||
'date': tryout.date.strftime('%Y-%m-%d'),
|
||||
'type': 'tryout', 'color': '#3b82f6',
|
||||
'extendedProps': {
|
||||
'location': tryout.location or 'TBD',
|
||||
'status': tryout.status,
|
||||
'description': tryout.description or '',
|
||||
'tryout_id': tryout.id,
|
||||
},
|
||||
})
|
||||
|
||||
for match in tryout.matches:
|
||||
match_color = '#10b981' if match.match_type == 'team_vs_team' else '#f59e0b'
|
||||
match_desc = match.description or ''
|
||||
@@ -158,18 +145,7 @@ def api_events_for_tryout(tryout_id):
|
||||
if not can_view and not is_registered and not player_in_match:
|
||||
return jsonify([])
|
||||
|
||||
events = [{
|
||||
'id': f'tryout_{tryout.id}',
|
||||
'title': f'Tryout: {tryout.title}',
|
||||
'date': tryout.date.strftime('%Y-%m-%d'),
|
||||
'type': 'tryout', 'color': '#3b82f6',
|
||||
'extendedProps': {
|
||||
'location': tryout.location or 'TBD',
|
||||
'status': tryout.status,
|
||||
'description': tryout.description or '',
|
||||
'tryout_id': tryout.id,
|
||||
},
|
||||
}]
|
||||
events = []
|
||||
|
||||
for match in tryout.matches:
|
||||
match_color = '#10b981' if match.match_type in ('team_vs_team', 'player_vs_player') else '#f59e0b'
|
||||
@@ -221,6 +197,10 @@ def create_match(tryout_id):
|
||||
flash('You do not have permission to schedule matches for this tryout.', 'danger')
|
||||
return redirect(url_for('tryouts.view_tryout', tryout_id=tryout_id))
|
||||
|
||||
if tryout.is_ended:
|
||||
flash('This tryout has ended. Matches can no longer be created or modified.', 'danger')
|
||||
return redirect(url_for('tryouts.view_tryout', tryout_id=tryout_id))
|
||||
|
||||
teams = Team.query.filter_by(tryout_id=tryout_id).all()
|
||||
registrations = TryoutRegistration.query.filter_by(tryout_id=tryout_id).all()
|
||||
all_players = [User.query.get(r.player_id) for r in registrations if User.query.get(r.player_id)]
|
||||
@@ -348,6 +328,10 @@ def edit_match(match_id):
|
||||
flash('You do not have permission to edit this match.', 'danger')
|
||||
return redirect(url_for('matches.calendar'))
|
||||
|
||||
if tryout.is_ended:
|
||||
flash('This tryout has ended. Matches can no longer be created or modified.', 'danger')
|
||||
return redirect(url_for('tryouts.view_tryout', tryout_id=tryout.id))
|
||||
|
||||
teams = Team.query.filter_by(tryout_id=tryout.id).all()
|
||||
registrations = TryoutRegistration.query.filter_by(tryout_id=tryout.id).all()
|
||||
all_players = [User.query.get(r.player_id) for r in registrations if r.player_id]
|
||||
@@ -503,6 +487,7 @@ def api_manageable_tryouts():
|
||||
manageable.append({
|
||||
'id': t.id, 'title': t.title,
|
||||
'date': t.date.strftime('%Y-%m-%d'),
|
||||
'end_date': t.end_date.strftime('%Y-%m-%d') if t.end_date else None,
|
||||
})
|
||||
return jsonify(manageable)
|
||||
|
||||
@@ -516,6 +501,9 @@ def delete_match(match_id):
|
||||
if not current_user.can_manage_this_tryout(tryout):
|
||||
flash('You do not have permission to delete this match.', 'danger')
|
||||
return redirect(url_for('matches.calendar'))
|
||||
if tryout.is_ended:
|
||||
flash('This tryout has ended. Matches can no longer be deleted.', 'danger')
|
||||
return redirect(url_for('tryouts.view_tryout', tryout_id=tryout.id))
|
||||
db.session.delete(match)
|
||||
db.session.commit()
|
||||
flash('Match deleted successfully.', 'success')
|
||||
|
||||
Reference in New Issue
Block a user