Files
MatchLiveTv/backend/app/controllers/admin/clubs_controller.rb
eminuxandCursor b88f44ab1c Completa i18n IT/EN/FR/DE/ES su sito pubblico, area autenticata e admin.
Tutte le view marketing, legali, viewer, dashboard e admin usano t(); mailer utente-facing e flash localizzati; admin con LocaleResolver e selettore lingua.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 00:38:50 +02:00

47 lines
1.5 KiB
Ruby

module Admin
class ClubsController < BaseController
before_action :set_club, only: %i[show grant_comped revoke_comped]
def index
@clubs = Club.includes(:teams, subscription: %i[plan 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.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: t("admin.flash.comped_granted", plan: Plan[params[:plan_slug]].name, club: @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: t("admin.flash.comped_revoked", club: @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