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:
2026-09-05 15:05:57 +02:00
co-authored by Cursor
parent d52434fb2e
commit a1f4c24a43
124 changed files with 6979 additions and 91 deletions
@@ -0,0 +1,45 @@
module Tournaments
class Invite
def self.call(tournament:, email:, scope_kind:, match_ids: [], court: nil, on_date: nil, invited_by:, note: nil)
new(
tournament: tournament,
email: email,
scope_kind: scope_kind,
match_ids: match_ids,
court: court,
on_date: on_date,
invited_by: invited_by,
note: note
).call
end
def initialize(tournament:, email:, scope_kind:, match_ids:, court:, on_date:, invited_by:, note: nil)
@tournament = tournament
@email = email.to_s.downcase.strip
@scope_kind = scope_kind.to_s
@match_ids = Array(match_ids).reject(&:blank?)
@court = court
@on_date = on_date
@invited_by = invited_by
@note = note.to_s.strip.presence
end
def call
Tournaments::Entitlements.new(@tournament.club).assert_writable!
raise ArgumentError, "Email non valida" if @email.blank?
token = TournamentBroadcastInvitation.generate_token
invitation = @tournament.broadcast_invitations.create!(
email: @email,
token_digest: Digest::SHA256.hexdigest(token),
scope_kind: @scope_kind,
match_ids: @match_ids,
court: @court,
on_date: @on_date,
note: @note,
expires_at: 7.days.from_now
)
[invitation, token]
end
end
end