Aggiunge i tornei con hub, pagina pubblica e tabellone per semifinali e finali.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -10,13 +10,22 @@ module Api
|
||||
|
||||
def index
|
||||
matches = @team.matches
|
||||
.includes(:team, :stream_sessions)
|
||||
.includes(:team, :stream_sessions, :home_participant, :away_participant)
|
||||
.order(Arel.sql("scheduled_at ASC NULLS LAST"), created_at: :desc)
|
||||
.select(&:coach_hub_visible?)
|
||||
render json: matches.map { |m| match_json(m) }
|
||||
unless current_user.club_admin?(@team.club)
|
||||
if @team.tournament_broadcast?
|
||||
assigned_ids = current_user.tournament_broadcast_assignments.select(:match_id)
|
||||
matches = matches.where(id: assigned_ids)
|
||||
end
|
||||
end
|
||||
render json: matches.select(&:coach_hub_visible?).map { |m| match_json(m) }
|
||||
end
|
||||
|
||||
def create
|
||||
if @team.tournament_broadcast?
|
||||
return render json: { error: "Le partite del torneo si programmano dal sito web." }, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
attrs = match_params.to_h
|
||||
attrs["sport_key"] = @team.sport_key
|
||||
normalize_scoring_rules!(attrs)
|
||||
@@ -112,9 +121,12 @@ module Api
|
||||
{
|
||||
id: match.id,
|
||||
team_id: match.team_id,
|
||||
team_name: team.name,
|
||||
opponent_name: match.opponent_name,
|
||||
location: match.location,
|
||||
team_name: match.home_display_name,
|
||||
opponent_name: match.away_display_name,
|
||||
location: match.court_or_location,
|
||||
court: match.court,
|
||||
tournament_id: match.tournament_id,
|
||||
tournament_name: match.tournament&.name,
|
||||
scheduled_at: match.scheduled_at,
|
||||
sport: match.sport_key,
|
||||
sport_key: match.sport_key,
|
||||
@@ -126,11 +138,11 @@ module Api
|
||||
scoring_rules: match.scoring_rules.presence,
|
||||
effective_scoring_rules: match.effective_scoring_rules,
|
||||
category: match.category,
|
||||
home_primary_color: team.effective_primary_color,
|
||||
home_secondary_color: team.effective_secondary_color,
|
||||
home_logo_url: api_absolute_url(team.effective_logo_url),
|
||||
opponent_primary_color: match.effective_opponent_primary_color,
|
||||
opponent_logo_url: api_absolute_url(match.opponent_logo_url),
|
||||
home_primary_color: match.home_participant&.effective_primary_color || team.effective_primary_color,
|
||||
home_secondary_color: match.home_participant&.effective_secondary_color || team.effective_secondary_color,
|
||||
home_logo_url: api_absolute_url(match.home_participant&.effective_logo_url || team.effective_logo_url),
|
||||
opponent_primary_color: match.away_participant&.effective_primary_color || match.effective_opponent_primary_color,
|
||||
opponent_logo_url: api_absolute_url(match.away_participant&.effective_logo_url || match.opponent_logo_url),
|
||||
**match_cover_json(match),
|
||||
active_session_id: active&.id,
|
||||
active_session_status: active&.status,
|
||||
|
||||
Reference in New Issue
Block a user