Files
MatchLiveTv/backend/app/controllers/admin/clubs_controller.rb
Emiliano Frascaro 9b40deeb61 Unifica admin società/squadre e YouTube Full con fallback MLTV.
Premium Full senza canale società usa il canale piattaforma come Light;
in app restano solo Match Live TV e YouTube Live.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 22:38:28 +02:00

47 lines
1.6 KiB
Ruby

module Admin
class ClubsController < BaseController
before_action :set_club, only: %i[show grant_comped revoke_comped]
def index
@clubs = Club.includes(:subscription, :teams, subscription: :plan, subscription: :admin_comped_by)
.order(:name)
end
def show
@subscription = @club.subscription || @club.build_subscription(plan: Plan["free"], status: "active")
@plans = Plan.ordered.reject { |p| p.slug == "free" }
@teams = @club.teams.includes(:youtube_credential).order(:name)
end
def grant_comped
Billing::AdminCompedSubscription.grant(
club: @club,
plan_slug: params.require(:plan_slug),
reason: params[:reason],
admin: current_admin_account
)
redirect_back_or_club notice: "Abbonamento omaggio #{Plan[params[:plan_slug]].name} attivato per #{@club.name}."
rescue Billing::AdminCompedSubscription::Error, ActiveRecord::RecordInvalid => e
redirect_back_or_club alert: e.message
end
def revoke_comped
Billing::AdminCompedSubscription.revoke(club: @club, admin: current_admin_account)
redirect_back_or_club notice: "Abbonamento omaggio revocato per #{@club.name}."
rescue Billing::AdminCompedSubscription::Error => e
redirect_back_or_club alert: e.message
end
private
def set_club
@club = Club.find(params[:id])
end
def redirect_back_or_club(notice: nil, alert: nil)
target = params[:return_to].presence || admin_club_path(@club)
redirect_to target, notice: notice, alert: alert
end
end
end