Club come entità principale, branding e fix infrastruttura streaming.
Introduce clubs con abbonamento, branding Active Storage e flusso registrazione società; corregge healthcheck MediaMTX (immagine distroless) e allinea dominio produzione matchlivetv.it. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,10 +4,11 @@ module Teams
|
||||
|
||||
def initialize(team)
|
||||
@team = team
|
||||
@club = team.club
|
||||
end
|
||||
|
||||
def subscription
|
||||
@subscription ||= @team.subscription || ensure_free_subscription!
|
||||
@subscription ||= @club.subscription || ensure_free_subscription!
|
||||
end
|
||||
|
||||
def plan
|
||||
@@ -59,7 +60,7 @@ module Teams
|
||||
end
|
||||
|
||||
def members_count_for(kind)
|
||||
@team.user_teams.where(role: "member", staff_kind: kind).count
|
||||
@team.user_teams.where(staff_kind: kind).count
|
||||
end
|
||||
|
||||
def pending_invitations_count
|
||||
@@ -75,8 +76,8 @@ module Teams
|
||||
end
|
||||
|
||||
def concurrent_streams_used
|
||||
StreamSession.joins(:match)
|
||||
.where(matches: { team_id: @team.id })
|
||||
StreamSession.joins(match: :team)
|
||||
.where(teams: { club_id: @club.id })
|
||||
.where(status: ACTIVE_STREAM_STATUSES)
|
||||
.count
|
||||
end
|
||||
@@ -101,7 +102,7 @@ module Teams
|
||||
platform = platform.to_s
|
||||
unless active?
|
||||
raise EntitlementError.new(
|
||||
"Abbonamento non attivo per questa squadra",
|
||||
"Abbonamento non attivo per la società",
|
||||
code: "subscription_inactive",
|
||||
billing_url: billing_url
|
||||
)
|
||||
@@ -196,7 +197,7 @@ module Teams
|
||||
end
|
||||
|
||||
def billing_url
|
||||
"#{MatchLiveTv.app_public_url.chomp('/')}/teams/#{@team.id}/billing"
|
||||
"#{MatchLiveTv.app_public_url.chomp('/')}/clubs/#{@club.id}/billing"
|
||||
end
|
||||
|
||||
def staff_manage_url
|
||||
@@ -232,8 +233,8 @@ module Teams
|
||||
private
|
||||
|
||||
def ensure_free_subscription!
|
||||
Billing::AssignPlan.call(team: @team, plan_slug: "free")
|
||||
@team.reload.subscription
|
||||
Billing::AssignPlan.call(club: @club, plan_slug: "free")
|
||||
@club.reload.subscription
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user