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>
This commit is contained in:
@@ -10,16 +10,16 @@ module Admin
|
||||
account = AdminAccount.find_by(username: params[:username]&.strip)
|
||||
if account&.authenticate(params[:password])
|
||||
session[:admin_account_id] = account.id
|
||||
redirect_to session.delete(:admin_return_to) || admin_root_path, notice: "Accesso effettuato"
|
||||
redirect_to session.delete(:admin_return_to) || admin_root_path, notice: t("admin.flash.login_success")
|
||||
else
|
||||
flash.now[:alert] = "Username o password non validi"
|
||||
flash.now[:alert] = t("admin.flash.invalid_credentials")
|
||||
render :new, status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
reset_session
|
||||
redirect_to admin_login_path, notice: "Disconnesso"
|
||||
redirect_to admin_login_path, notice: t("admin.flash.logout_success")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,20 +3,40 @@ module Admin
|
||||
layout "admin"
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
before_action :set_admin_locale
|
||||
before_action :require_admin_login
|
||||
|
||||
include ::AdminHelper
|
||||
helper ApplicationHelper
|
||||
helper RecordingsArchiveHelper
|
||||
helper_method :current_admin_account, :admin_logged_in?
|
||||
helper_method :current_admin_account, :admin_logged_in?, :current_locale, :language_options, :current_language_option
|
||||
|
||||
private
|
||||
|
||||
def set_admin_locale
|
||||
I18n.locale = LocaleResolver.resolve(
|
||||
cookie_jar: request.cookie_jar,
|
||||
accept_language: request.get_header("HTTP_ACCEPT_LANGUAGE")
|
||||
)
|
||||
end
|
||||
|
||||
def current_locale
|
||||
I18n.locale
|
||||
end
|
||||
|
||||
def language_options
|
||||
LocaleResolver.language_options
|
||||
end
|
||||
|
||||
def current_language_option
|
||||
LocaleResolver.current_language_option
|
||||
end
|
||||
|
||||
def require_admin_login
|
||||
return if admin_logged_in?
|
||||
|
||||
session[:admin_return_to] = request.fullpath unless request.path == admin_login_path
|
||||
redirect_to admin_login_path, alert: "Accedi per continuare"
|
||||
redirect_to admin_login_path, alert: t("admin.flash.login_required")
|
||||
end
|
||||
|
||||
def current_admin_account
|
||||
|
||||
@@ -11,7 +11,7 @@ module Admin
|
||||
payment = Billing::Payment.find(params[:payment_id])
|
||||
Billing::AttachPaymentInvoice.call(payment: payment, pdf: params[:pdf])
|
||||
redirect_to admin_billing_path(billing_redirect_params(payment)),
|
||||
notice: "Fattura caricata e inviata a #{payment.club.billing_email}."
|
||||
notice: t("admin.flash.invoice_uploaded", email: payment.club.billing_email)
|
||||
rescue Billing::AttachPaymentInvoice::Error, Billing::IssueInvoice::Error => e
|
||||
payment ||= Billing::Payment.find_by(id: params[:payment_id])
|
||||
redirect_to admin_billing_path(payment ? billing_redirect_params(payment) : {}),
|
||||
|
||||
@@ -8,7 +8,7 @@ module Admin
|
||||
end
|
||||
|
||||
def new
|
||||
redirect_to admin_billing_path(club_id: @club.id), alert: "Carica il PDF dalla lista «Pagamenti da fatturare»."
|
||||
redirect_to admin_billing_path(club_id: @club.id), alert: t("admin.flash.invoice_upload_hint")
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -18,7 +18,7 @@ module Admin
|
||||
|
||||
if @invoice.save
|
||||
redirect_to edit_admin_club_billing_invoice_path(@club, @invoice),
|
||||
notice: "Bozza creata. Carica il PDF dalla pagina Fatturazione o qui sotto."
|
||||
notice: t("admin.flash.invoice_draft_created")
|
||||
else
|
||||
@payment = @invoice.billing_payment
|
||||
flash.now[:alert] = @invoice.errors.full_messages.join(", ")
|
||||
@@ -36,9 +36,9 @@ module Admin
|
||||
if issuing?
|
||||
Billing::IssueInvoice.call(invoice: @invoice, pdf: params.dig(:billing_invoice, :pdf))
|
||||
redirect_to admin_billing_path(club_id: @club.id),
|
||||
notice: "Fattura #{@invoice.number} emessa e inviata a #{@club.billing_email}."
|
||||
notice: t("admin.flash.invoice_issued", number: @invoice.number, email: @club.billing_email)
|
||||
elsif @invoice.save
|
||||
redirect_to admin_billing_path(club_id: @club.id), notice: "Fattura #{@invoice.number} aggiornata."
|
||||
redirect_to admin_billing_path(club_id: @club.id), notice: t("admin.flash.invoice_updated", number: @invoice.number)
|
||||
else
|
||||
@payment = @invoice.billing_payment
|
||||
flash.now[:alert] = @invoice.errors.full_messages.join(", ")
|
||||
@@ -61,7 +61,7 @@ module Admin
|
||||
end
|
||||
|
||||
def issuing?
|
||||
params[:commit].to_s == "Emetti e invia via email"
|
||||
params[:commit_action].to_s == "issue"
|
||||
end
|
||||
|
||||
def invoice_params
|
||||
|
||||
@@ -20,14 +20,14 @@ module Admin
|
||||
reason: params[:reason],
|
||||
admin: current_admin_account
|
||||
)
|
||||
redirect_back_or_club notice: "Abbonamento omaggio #{Plan[params[:plan_slug]].name} attivato per #{@club.name}."
|
||||
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: "Abbonamento omaggio revocato per #{@club.name}."
|
||||
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
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
module Admin
|
||||
class LocalesController < BaseController
|
||||
skip_before_action :require_admin_login
|
||||
|
||||
def update
|
||||
locale = LocaleResolver.persist!(cookies, params[:locale])
|
||||
I18n.locale = locale
|
||||
redirect_back fallback_location: admin_root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -9,19 +9,19 @@ module Admin
|
||||
def acknowledge
|
||||
incident = Ops::Incident.find(params[:id])
|
||||
incident.acknowledge!
|
||||
redirect_to admin_ops_path, notice: "Incidente preso in carico"
|
||||
redirect_to admin_ops_path, notice: t("admin.flash.ops_acknowledged")
|
||||
end
|
||||
|
||||
def resolve
|
||||
incident = Ops::Incident.find(params[:id])
|
||||
incident.resolve!
|
||||
redirect_to admin_ops_path, notice: "Incidente risolto"
|
||||
redirect_to admin_ops_path, notice: t("admin.flash.ops_resolved")
|
||||
end
|
||||
|
||||
def mute
|
||||
incident = Ops::Incident.find(params[:id])
|
||||
incident.mute!(duration: 24.hours)
|
||||
redirect_to admin_ops_path, notice: "Notifiche sospese per 24 ore"
|
||||
redirect_to admin_ops_path, notice: t("admin.flash.ops_muted")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,22 +5,22 @@ module Admin
|
||||
|
||||
def update
|
||||
unless current_admin_account.authenticate(params[:current_password])
|
||||
flash.now[:alert] = "Password attuale non corretta"
|
||||
flash.now[:alert] = t("admin.flash.password_current_incorrect")
|
||||
return render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
if params[:password].blank? || params[:password].length < 8
|
||||
flash.now[:alert] = "La nuova password deve avere almeno 8 caratteri"
|
||||
flash.now[:alert] = t("admin.flash.password_too_short")
|
||||
return render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
if params[:password] != params[:password_confirmation]
|
||||
flash.now[:alert] = "Le password non coincidono"
|
||||
flash.now[:alert] = t("admin.flash.password_mismatch")
|
||||
return render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
if current_admin_account.update(password: params[:password])
|
||||
redirect_to admin_root_path, notice: "Password aggiornata"
|
||||
redirect_to admin_root_path, notice: t("admin.flash.password_updated")
|
||||
else
|
||||
flash.now[:alert] = current_admin_account.errors.full_messages.to_sentence
|
||||
render :edit, status: :unprocessable_entity
|
||||
|
||||
@@ -12,28 +12,28 @@ module Admin
|
||||
def stop
|
||||
@session = StreamSession.find(params[:id])
|
||||
if @session.terminal?
|
||||
redirect_to admin_session_path(@session), alert: "Sessione già terminata (#{@session.status})."
|
||||
redirect_to admin_session_path(@session), alert: t("admin.flash.session_already_terminated", status: @session.status)
|
||||
return
|
||||
end
|
||||
|
||||
Sessions::Stop.new(@session).call
|
||||
redirect_to admin_session_path(@session), notice: "Sessione terminata."
|
||||
redirect_to admin_session_path(@session), notice: t("admin.flash.session_stopped")
|
||||
rescue StandardError => e
|
||||
Rails.logger.error("[admin] stop session #{@session.id}: #{e.class} #{e.message}")
|
||||
redirect_to admin_session_path(@session), alert: "Errore durante la chiusura: #{e.message}"
|
||||
redirect_to admin_session_path(@session), alert: t("admin.flash.session_stop_error", error: e.message)
|
||||
end
|
||||
|
||||
def regia_link
|
||||
@session = StreamSession.find(params[:id])
|
||||
if @session.terminal?
|
||||
redirect_to admin_session_path(@session), alert: "Sessione terminata: impossibile generare il link regia."
|
||||
redirect_to admin_session_path(@session), alert: t("admin.flash.session_terminated_no_regia")
|
||||
return
|
||||
end
|
||||
|
||||
access = Sessions::RegiaAccess.new(@session)
|
||||
token = access.issue_token!
|
||||
redirect_to admin_session_path(@session),
|
||||
notice: "Link regia generato.",
|
||||
notice: t("admin.flash.session_regia_generated"),
|
||||
flash: {
|
||||
regia_url: access.url(token),
|
||||
regia_expires_at: @session.regia_token_expires_at&.iso8601
|
||||
|
||||
@@ -2,7 +2,7 @@ module Admin
|
||||
class YoutubeController < Admin::BaseController
|
||||
def platform
|
||||
if ENV["YOUTUBE_CLIENT_ID"].blank?
|
||||
redirect_to admin_root_path, alert: "Configura YOUTUBE_CLIENT_ID e YOUTUBE_CLIENT_SECRET in .env"
|
||||
redirect_to admin_root_path, alert: t("admin.flash.youtube_not_configured")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ module Public
|
||||
@club,
|
||||
plan: premium_checkout_return_params[:plan],
|
||||
interval: premium_checkout_return_params[:interval]
|
||||
), notice: "Dati salvati. Procedi con il pagamento."
|
||||
), notice: t("flash.club_billing.profile_saved_proceed_payment")
|
||||
else
|
||||
redirect_to public_club_billing_path(@club), notice: "Dati di fatturazione aggiornati."
|
||||
redirect_to public_club_billing_path(@club), notice: t("flash.club_billing.profile_updated")
|
||||
end
|
||||
else
|
||||
flash.now[:alert] = @club.errors.full_messages.join(", ")
|
||||
@@ -27,25 +27,25 @@ module Public
|
||||
|
||||
def cancel_subscription
|
||||
unless MatchLiveTv.stripe_enabled?
|
||||
redirect_to public_club_billing_path(@club), alert: "Stripe non configurato."
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.club_billing.stripe_not_configured")
|
||||
return
|
||||
end
|
||||
|
||||
Billing::Stripe::CancelSubscription.call(club: @club)
|
||||
sub = @club.subscription.reload
|
||||
date = sub.current_period_end ? helpers.l_local(sub.current_period_end.to_date) : "fine periodo"
|
||||
date = sub.current_period_end ? helpers.l_local(sub.current_period_end.to_date) : t("billing.subscription_status.end_of_period")
|
||||
redirect_to public_club_billing_path(@club),
|
||||
notice: "Abbonamento disdetto. Resta attivo fino al #{date}; da quel giorno passerai al piano Free."
|
||||
notice: t("flash.club_billing.subscription_canceled", date: date)
|
||||
rescue ArgumentError, RuntimeError => e
|
||||
redirect_to public_club_billing_path(@club), alert: e.message
|
||||
rescue ::Stripe::StripeError => e
|
||||
redirect_to public_club_billing_path(@club), alert: "Errore Stripe: #{e.message}"
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.club_billing.stripe_error", message: e.message)
|
||||
end
|
||||
|
||||
def download_invoice
|
||||
invoice = @club.billing_invoices.find(params[:invoice_id])
|
||||
unless invoice.pdf.attached?
|
||||
redirect_to public_club_billing_path(@club), alert: "PDF fattura non disponibile."
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.club_billing.invoice_pdf_unavailable")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ module Public
|
||||
@selected_team = @schedulable_teams.find { |t| t.id.to_s == params[:team_id].to_s }
|
||||
unless @selected_team
|
||||
@match = default_match_for_form
|
||||
flash.now[:alert] = "Seleziona una squadra valida."
|
||||
flash.now[:alert] = t("flash.club_matches.invalid_team")
|
||||
return render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ module Public
|
||||
match_params.merge(sport: @selected_team.sport, sets_to_win: 3)
|
||||
)
|
||||
redirect_to public_live_index_path(club_id: @club.id),
|
||||
notice: "Partita programmata: #{@selected_team.name} vs #{@match.opponent_name}."
|
||||
notice: t("flash.club_matches.scheduled", team: @selected_team.name, opponent: @match.opponent_name)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@match = @selected_team.matches.build(match_params)
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
@@ -44,7 +44,7 @@ module Public
|
||||
return if @schedulable_teams.any?
|
||||
|
||||
redirect_to public_live_index_path(club_id: @club.id),
|
||||
alert: "Non hai permessi per programmare partite in questa società."
|
||||
alert: t("flash.club_matches.no_schedulable_teams")
|
||||
end
|
||||
|
||||
def resolve_selected_team
|
||||
|
||||
@@ -22,7 +22,7 @@ module Public
|
||||
return if current_user.owned_clubs.exists?(id: @club.id)
|
||||
return if current_user.manageable_teams.joins(:club).exists?(clubs: { id: @club.id })
|
||||
|
||||
redirect_to public_clubs_path, alert: "Non autorizzato"
|
||||
redirect_to public_clubs_path, alert: t("flash.club_recordings.not_authorized")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module Public
|
||||
|
||||
def create
|
||||
if current_user.owned_clubs.exists?
|
||||
redirect_to public_club_path(current_user.primary_club), alert: "Hai già registrato una società"
|
||||
redirect_to public_club_path(current_user.primary_club), alert: t("flash.clubs.already_registered")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ module Public
|
||||
|
||||
ClubMembership.create!(user: current_user, club: club, role: "owner")
|
||||
|
||||
first_team_name = params.dig(:first_team, :name).presence || "Prima squadra"
|
||||
first_team_name = params.dig(:first_team, :name).presence || t("club.new.default_first_team_name")
|
||||
club.teams.create!(
|
||||
name: first_team_name,
|
||||
sport: club.sport
|
||||
@@ -34,14 +34,14 @@ module Public
|
||||
if plan.in?(%w[premium_light premium_full]) && MatchLiveTv.stripe_enabled?
|
||||
unless club.billing_profile_complete?
|
||||
redirect_to public_club_billing_profile_path(club, plan: plan, interval: checkout_interval_param),
|
||||
alert: "Completa i dati di fatturazione prima di attivare un piano premium."
|
||||
alert: t("flash.clubs.complete_billing_first")
|
||||
return
|
||||
end
|
||||
|
||||
interval = checkout_interval_param
|
||||
redirect_to public_club_checkout_path(club, plan: plan, interval: interval)
|
||||
else
|
||||
redirect_to public_club_path(club), notice: "Società e prima squadra create."
|
||||
redirect_to public_club_path(club), notice: t("flash.clubs.created")
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
@@ -66,7 +66,7 @@ module Public
|
||||
@club.assign_attributes(club_params)
|
||||
attach_branding_logo(@club)
|
||||
@club.save!
|
||||
redirect_to public_club_path(@club), notice: "Società aggiornata."
|
||||
redirect_to public_club_path(@club), notice: t("flash.clubs.updated")
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -88,12 +88,12 @@ module Public
|
||||
require_club_owner!(@club)
|
||||
if @club.subscription&.admin_comped?
|
||||
redirect_to public_club_billing_path(@club),
|
||||
alert: "Il piano è un abbonamento omaggio gestito da Match Live TV. Per passare a un abbonamento a pagamento contatta il supporto."
|
||||
alert: t("flash.clubs.comped_change_denied")
|
||||
return
|
||||
end
|
||||
|
||||
unless MatchLiveTv.stripe_enabled?
|
||||
redirect_to public_club_billing_path(@club), alert: "Pagamenti non ancora configurati sul server"
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.clubs.stripe_not_configured")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -105,15 +105,15 @@ module Public
|
||||
if sub&.stripe_subscription_id.present? && sub.active? &&
|
||||
sub.plan.slug == plan_slug && sub.billing_interval == interval && !sub.plan_change_pending?
|
||||
redirect_to public_club_billing_path(@club),
|
||||
notice: "Sei già su #{target_plan.name} (#{Billing::Stripe::PriceCatalog.label(plan_slug: plan_slug, interval: interval)})."
|
||||
notice: t("flash.clubs.already_on_plan", plan: target_plan.name, price: Billing::Stripe::PriceCatalog.label(plan_slug: plan_slug, interval: interval))
|
||||
return
|
||||
end
|
||||
|
||||
if sub&.plan_change_pending? && sub.pending_plan&.slug == plan_slug &&
|
||||
sub.pending_billing_interval == interval
|
||||
when_label = sub.current_period_end.present? ? I18n.l(sub.current_period_end, format: :long) : "il prossimo rinnovo"
|
||||
when_label = sub.current_period_end.present? ? I18n.l(sub.current_period_end, format: :long) : t("billing.messages.next_renewal")
|
||||
redirect_to public_club_billing_path(@club),
|
||||
notice: "Il passaggio a #{target_plan.name} è già programmato dal #{when_label}."
|
||||
notice: t("flash.clubs.change_already_scheduled", plan: target_plan.name, date: when_label)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -134,7 +134,7 @@ module Public
|
||||
redirect_to public_club_billing_path(@club), alert: e.message
|
||||
rescue ::Stripe::StripeError => e
|
||||
Rails.logger.warn("[Stripe checkout] #{e.message}")
|
||||
redirect_to public_club_billing_path(@club), alert: "Errore Stripe: #{e.message}"
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.clubs.stripe_error", message: e.message)
|
||||
end
|
||||
|
||||
def youtube_connect
|
||||
@@ -143,7 +143,7 @@ module Public
|
||||
entitlements.assert_can_connect_youtube!
|
||||
|
||||
if ENV["YOUTUBE_CLIENT_ID"].blank?
|
||||
redirect_to public_club_path(@club), alert: "YouTube OAuth non configurato sul server"
|
||||
redirect_to public_club_path(@club), alert: t("flash.clubs.youtube_oauth_not_configured")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -161,13 +161,13 @@ module Public
|
||||
def youtube_disconnect
|
||||
require_club_owner!(@club)
|
||||
@club.youtube_credential&.destroy!
|
||||
redirect_to public_club_path(@club), notice: "Canale YouTube della società scollegato"
|
||||
redirect_to public_club_path(@club), notice: t("flash.clubs.youtube_disconnected")
|
||||
end
|
||||
|
||||
def portal
|
||||
require_club_owner!(@club)
|
||||
unless MatchLiveTv.stripe_enabled?
|
||||
redirect_to public_club_billing_path(@club), alert: "Portale pagamenti non configurato"
|
||||
redirect_to public_club_billing_path(@club), alert: t("flash.clubs.portal_not_configured")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -204,7 +204,7 @@ module Public
|
||||
@club,
|
||||
plan: plan_slug,
|
||||
interval: params[:interval].presence
|
||||
), alert: "Completa i dati di fatturazione prima di attivare un piano premium."
|
||||
), alert: t("flash.clubs.complete_billing_first")
|
||||
end
|
||||
|
||||
def checkout_interval_param
|
||||
@@ -236,10 +236,10 @@ module Public
|
||||
def apply_checkout_flash!
|
||||
case params[:checkout]
|
||||
when "success"
|
||||
plan_name = @subscription&.plan&.name || "premium"
|
||||
flash.now[:notice] = "Pagamento completato! Piano attivo: #{plan_name}."
|
||||
plan_name = @subscription&.plan&.name || "Premium"
|
||||
flash.now[:notice] = t("flash.clubs.checkout_success", plan: plan_name)
|
||||
when "canceled"
|
||||
flash.now[:alert] = "Pagamento annullato. Nessun addebito è stato effettuato."
|
||||
flash.now[:alert] = t("flash.clubs.checkout_canceled")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,24 +4,24 @@ module Public
|
||||
@token = params[:token]
|
||||
@invitation = TeamInvitation.pending.find_by(token_digest: Digest::SHA256.hexdigest(@token.to_s))
|
||||
unless @invitation
|
||||
redirect_to public_pricing_path, alert: "Invito non valido o scaduto"
|
||||
redirect_to public_pricing_path, alert: t("flash.invitations.invalid_or_expired")
|
||||
end
|
||||
end
|
||||
|
||||
def accept
|
||||
invitation = TeamInvitation.pending.find_by(token_digest: Digest::SHA256.hexdigest(params[:token].to_s))
|
||||
return redirect_to public_pricing_path, alert: "Invito non valido" unless invitation
|
||||
return redirect_to public_pricing_path, alert: t("flash.invitations.invalid") unless invitation
|
||||
|
||||
if logged_in?
|
||||
if current_user.email.downcase != invitation.email.downcase
|
||||
redirect_to public_pricing_path, alert: "Questo invito è per #{invitation.email}"
|
||||
redirect_to public_pricing_path, alert: t("flash.invitations.wrong_email", email: invitation.email)
|
||||
return
|
||||
end
|
||||
invitation.accept!(current_user)
|
||||
redirect_to public_team_details_path(invitation.team), notice: "Sei entrato nella squadra!"
|
||||
redirect_to public_team_details_path(invitation.team), notice: t("flash.invitations.joined_team")
|
||||
else
|
||||
session[:pending_invite_token] = params[:token]
|
||||
redirect_to public_signup_path, notice: "Registrati con #{invitation.email} per accettare l'invito"
|
||||
redirect_to public_signup_path, notice: t("flash.invitations.signup_to_accept", email: invitation.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ module Public
|
||||
match_params.merge(sport: @team.sport, sets_to_win: match_params[:sets_to_win].presence || 3)
|
||||
)
|
||||
redirect_to public_team_matches_path(@team),
|
||||
notice: "Partita programmata: #{@match.opponent_name}. Avvia lo streaming dall’app quando sei in palestra."
|
||||
notice: t("flash.matches.scheduled", opponent: @match.opponent_name)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@match = @team.matches.build(match_params)
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
@@ -37,7 +37,7 @@ module Public
|
||||
|
||||
def update
|
||||
@match.update!(match_params)
|
||||
redirect_to public_team_matches_path(@team), notice: "Partita aggiornata."
|
||||
redirect_to public_team_matches_path(@team), notice: t("flash.matches.updated")
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
render :edit, status: :unprocessable_entity
|
||||
@@ -47,12 +47,12 @@ module Public
|
||||
active = active_session_for(@match)
|
||||
if active&.resumable?
|
||||
redirect_to public_team_matches_path(@team),
|
||||
alert: "Chiudi la diretta prima di eliminare questa partita."
|
||||
alert: t("flash.matches.close_live_before_delete")
|
||||
return
|
||||
end
|
||||
|
||||
@match.destroy!
|
||||
redirect_to public_team_matches_path(@team), notice: "Partita eliminata."
|
||||
redirect_to public_team_matches_path(@team), notice: t("flash.matches.deleted")
|
||||
end
|
||||
|
||||
private
|
||||
@@ -66,7 +66,7 @@ module Public
|
||||
return if current_user.can_schedule_for?(@team)
|
||||
|
||||
redirect_to public_team_details_path(@team),
|
||||
alert: "Solo un responsabile trasmissione o il titolare della società possono programmare le partite."
|
||||
alert: t("flash.matches.schedule_denied")
|
||||
end
|
||||
|
||||
def set_match
|
||||
|
||||
@@ -11,14 +11,14 @@ module Public
|
||||
end
|
||||
|
||||
redirect_to public_login_path,
|
||||
notice: "Se l'email è registrata, riceverai a breve un link per reimpostare la password."
|
||||
notice: t("flash.password_resets.email_sent")
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = User.find_by_password_reset_token(params[:token])
|
||||
if @user.nil? || @user.password_reset_expired?
|
||||
redirect_to new_public_password_reset_path,
|
||||
alert: "Link non valido o scaduto. Richiedi un nuovo reset password."
|
||||
alert: t("flash.password_resets.invalid_or_expired_link")
|
||||
return
|
||||
end
|
||||
@token = params[:token]
|
||||
@@ -28,25 +28,25 @@ module Public
|
||||
@user = User.find_by_password_reset_token(params[:token])
|
||||
if @user.nil? || @user.password_reset_expired?
|
||||
redirect_to new_public_password_reset_path,
|
||||
alert: "Link non valido o scaduto. Richiedi un nuovo reset password."
|
||||
alert: t("flash.password_resets.invalid_or_expired_link")
|
||||
return
|
||||
end
|
||||
|
||||
if params[:password].blank? || params[:password].length < 8
|
||||
flash.now[:alert] = "La password deve avere almeno 8 caratteri"
|
||||
flash.now[:alert] = t("flash.password_resets.password_min_length")
|
||||
@token = params[:token]
|
||||
return render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
if params[:password] != params[:password_confirmation]
|
||||
flash.now[:alert] = "Le password non coincidono"
|
||||
flash.now[:alert] = t("flash.password_resets.password_mismatch")
|
||||
@token = params[:token]
|
||||
return render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
@user.update!(password: params[:password])
|
||||
@user.clear_password_reset!
|
||||
redirect_to public_login_path, notice: "Password aggiornata. Ora puoi accedere."
|
||||
redirect_to public_login_path, notice: t("flash.password_resets.password_updated")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module Public
|
||||
def create
|
||||
unless params[:accept_terms] == "1"
|
||||
@user = User.new(user_params.merge(role: "coach"))
|
||||
flash.now[:alert] = "Devi accettare l’informativa privacy e i termini di servizio per registrarti."
|
||||
flash.now[:alert] = t("flash.registrations.accept_terms_required")
|
||||
return render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
@@ -20,10 +20,10 @@ module Public
|
||||
invitation = TeamInvitation.pending.find_by(token_digest: Digest::SHA256.hexdigest(token))
|
||||
if invitation && invitation.email.downcase == @user.email.downcase
|
||||
invitation.accept!(@user)
|
||||
return redirect_to public_team_details_path(invitation.team), notice: "Benvenuto nella squadra!"
|
||||
return redirect_to public_team_details_path(invitation.team), notice: t("flash.registrations.welcome_to_team")
|
||||
end
|
||||
end
|
||||
redirect_to public_new_club_path, notice: "Account creato. Ora registra la tua società."
|
||||
redirect_to public_new_club_path, notice: t("flash.registrations.account_created")
|
||||
else
|
||||
flash.now[:alert] = @user.errors.full_messages.join(", ")
|
||||
render :new, status: :unprocessable_entity
|
||||
|
||||
@@ -42,7 +42,7 @@ module Public
|
||||
|
||||
def download
|
||||
unless download_allowed?
|
||||
redirect_to public_replay_path(@session), alert: "Download non disponibile"
|
||||
redirect_to public_replay_path(@session), alert: t("flash.replay.download_unavailable")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -105,13 +105,13 @@ module Public
|
||||
@recording = Recording.not_deleted.find_by(stream_session: @session)
|
||||
return if @recording
|
||||
|
||||
redirect_to public_live_path(@session), alert: "Replay non disponibile"
|
||||
redirect_to public_live_path(@session), alert: t("flash.replay.not_available")
|
||||
end
|
||||
|
||||
def authorize_replay_access!
|
||||
return if Recordings::AccessPolicy.new(@recording, viewer: current_user).allowed?
|
||||
|
||||
redirect_to public_live_index_path, alert: "Replay non disponibile"
|
||||
redirect_to public_live_index_path, alert: t("flash.replay.not_available")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,16 +17,16 @@ module Public
|
||||
else
|
||||
public_new_club_path
|
||||
end
|
||||
redirect_to dest, notice: "Bentornato!"
|
||||
redirect_to dest, notice: t("flash.sessions.welcome_back")
|
||||
else
|
||||
flash.now[:alert] = "Email o password non validi"
|
||||
flash.now[:alert] = t("flash.sessions.invalid_credentials")
|
||||
render :new, status: :unauthorized
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
reset_session
|
||||
redirect_to public_pricing_path, notice: "Disconnesso"
|
||||
redirect_to public_pricing_path, notice: t("flash.sessions.logged_out")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module Public
|
||||
member = @team.roster_members.build(member_params)
|
||||
attach_photo(member)
|
||||
member.save!
|
||||
redirect_to public_team_details_path(@team), notice: "#{member.full_name} aggiunto all'organico."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.team_roster_members.added", name: member.full_name)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
redirect_to public_team_details_path(@team), alert: e.record.errors.full_messages.join(", ")
|
||||
end
|
||||
@@ -22,7 +22,7 @@ module Public
|
||||
@member.assign_attributes(member_params)
|
||||
attach_photo(@member)
|
||||
@member.save!
|
||||
redirect_to public_team_details_path(@team), notice: "Scheda aggiornata."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.team_roster_members.updated")
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@club = @team.club
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
@@ -32,7 +32,7 @@ module Public
|
||||
def destroy
|
||||
name = @member.full_name
|
||||
@member.destroy!
|
||||
redirect_to public_team_details_path(@team), notice: "#{name} rimosso dall'organico."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.team_roster_members.removed", name: name)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -19,7 +19,7 @@ module Public
|
||||
require_club_owner!(@club)
|
||||
team = @club.teams.create!(team_params)
|
||||
attach_branding_logo(team)
|
||||
redirect_to public_club_path(@club), notice: "Squadra «#{team.name}» aggiunta."
|
||||
redirect_to public_club_path(@club), notice: t("flash.teams.added", name: team.name)
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
render :new, status: :unprocessable_entity
|
||||
@@ -49,7 +49,7 @@ module Public
|
||||
attach_branding_logo(@team)
|
||||
attach_team_photo(@team)
|
||||
@team.save!
|
||||
redirect_to public_team_details_path(@team), notice: "Squadra aggiornata."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.teams.updated")
|
||||
rescue ActiveRecord::RecordInvalid => e
|
||||
@club = @team.club
|
||||
flash.now[:alert] = e.record.errors.full_messages.join(", ")
|
||||
@@ -66,7 +66,7 @@ module Public
|
||||
membership = current_user.user_teams.find_or_initialize_by(team: @team)
|
||||
membership.role = "member" if membership.new_record?
|
||||
Teams::StaffAssignment.call(team: @team, user: current_user, membership: membership)
|
||||
redirect_to public_team_details_path(@team), notice: "Il tuo account è ora responsabile trasmissione."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.teams.now_staff")
|
||||
rescue Teams::StaffAssignmentError, Teams::EntitlementError => e
|
||||
redirect_to public_team_details_path(@team), alert: e.message
|
||||
end
|
||||
@@ -75,7 +75,7 @@ module Public
|
||||
require_club_owner_for_team!(@team)
|
||||
membership = current_user.user_teams.find_by(team: @team)
|
||||
membership&.update!(staff_kind: nil)
|
||||
redirect_to public_team_details_path(@team), notice: "Ruolo staff rimosso dal tuo account."
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.teams.staff_role_removed")
|
||||
end
|
||||
|
||||
def create_invitation
|
||||
@@ -95,7 +95,7 @@ module Public
|
||||
expires_at: 7.days.from_now
|
||||
)
|
||||
@invite_url = join_public_invitation_url(token: token)
|
||||
flash.now[:notice] = "Link invito generato (valido 7 giorni)"
|
||||
flash.now[:notice] = t("flash.teams.invite_link_generated")
|
||||
render :invite
|
||||
rescue Teams::EntitlementError, Teams::StaffAssignmentError => e
|
||||
redirect_to public_team_invite_path(@team), alert: e.message
|
||||
@@ -105,14 +105,14 @@ module Public
|
||||
require_club_owner_for_team!(@team)
|
||||
ut = @team.user_teams.find_by!(user_id: params[:user_id], role: "member")
|
||||
ut.destroy!
|
||||
redirect_to public_team_details_path(@team), notice: "Accesso revocato"
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.teams.access_revoked")
|
||||
end
|
||||
|
||||
def destroy_invitation
|
||||
require_club_owner_for_team!(@team)
|
||||
inv = @team.team_invitations.pending.find(params[:invitation_id])
|
||||
inv.destroy!
|
||||
redirect_to public_team_details_path(@team), notice: "Invito annullato"
|
||||
redirect_to public_team_details_path(@team), notice: t("flash.teams.invitation_canceled")
|
||||
end
|
||||
|
||||
def youtube_connect
|
||||
@@ -125,7 +125,7 @@ module Public
|
||||
def youtube_disconnect
|
||||
require_club_owner_for_team!(@team)
|
||||
@team.club.youtube_credential&.destroy!
|
||||
redirect_to public_club_path(@team.club), notice: "Canale YouTube della società scollegato"
|
||||
redirect_to public_club_path(@team.club), notice: t("flash.teams.youtube_disconnected")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -7,15 +7,15 @@ module Public
|
||||
def require_login!
|
||||
return if logged_in?
|
||||
|
||||
redirect_to public_login_path, alert: "Accedi per continuare"
|
||||
redirect_to public_login_path, alert: t("flash.web_base.login_required")
|
||||
end
|
||||
|
||||
def require_club_owner!(club)
|
||||
redirect_to public_prezzi_path, alert: "Accesso non consentito" unless club.owned_by?(current_user)
|
||||
redirect_to public_prezzi_path, alert: t("flash.web_base.access_denied") unless club.owned_by?(current_user)
|
||||
end
|
||||
|
||||
def require_club_owner_for_team!(team)
|
||||
redirect_to public_prezzi_path, alert: "Accesso non consentito" unless team.club&.owned_by?(current_user)
|
||||
redirect_to public_prezzi_path, alert: t("flash.web_base.access_denied") unless team.club&.owned_by?(current_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user