Commit 4daa1528 authored by Your Name's avatar Your Name

Add refresh fixture button for clients

- Added refresh_fixture route that resets fixture_active_time to null
- Added 'Refresh' button (🔄) to fixture detail page
- When clicked, clients will download the fixture as a new update
parent 2ec209bc
......@@ -588,6 +588,47 @@ def save_fixture_as_new(fixture_id):
return redirect(url_for('main.fixture_detail', fixture_id=fixture_id))
@csrf.exempt
@bp.route('/fixture/<fixture_id>/refresh')
@login_required
@require_active_user
def refresh_fixture(fixture_id):
"""Refresh a fixture so clients will download it as a new update"""
try:
from app.models import Match
from app import db
import time
# Verify fixture exists and user has access
if not current_user.is_admin:
matches = Match.query.filter_by(fixture_id=fixture_id, created_by=current_user.id).all()
else:
matches = Match.query.filter_by(fixture_id=fixture_id).all()
if not matches:
flash('Fixture not found', 'error')
return redirect(url_for('main.fixture_detail', fixture_id=fixture_id))
# Reset fixture_active_time to null so clients will see it as new
current_time = int(time.time())
for match in matches:
match.fixture_active_time = None
match.active_status = False
db.session.commit()
flash(f'Fixture refreshed! It will be downloaded by clients as a new update.', 'success')
return redirect(url_for('main.fixture_detail', fixture_id=fixture_id))
except Exception as e:
db.session.rollback()
logger.error(f"Refresh fixture error: {str(e)}")
flash(f'Error refreshing fixture: {str(e)}', 'error')
return redirect(url_for('main.fixture_detail', fixture_id=fixture_id))
@csrf.exempt
@bp.route('/fixture/<fixture_id>/delete', methods=['POST'])
@login_required
......
......@@ -355,6 +355,13 @@
</a>
{% endif %}
<a href="{{ url_for('main.refresh_fixture', fixture_id=fixture_info.fixture_id) }}"
class="btn btn-warning"
onclick="return confirm('This will refresh the fixture so clients will download it as a new update. Continue?');"
title="Refresh fixture for clients">
🔄 Refresh
</a>
<form method="POST" action="{{ url_for('main.delete_fixture', fixture_id=fixture_info.fixture_id) }}"
style="display: inline;"
onsubmit="return confirm('Are you sure you want to delete this entire fixture and all {{ fixture_info.total_matches }} matches? This action cannot be undone.');">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment