Files
Emiliano Frascaro 4083bc5dee 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>
2026-05-27 09:16:24 +02:00

44 lines
879 B
Ruby

module Brandable
extend ActiveSupport::Concern
HEX_COLOR = /\A#[0-9A-Fa-f]{6}\z/
included do
has_one_attached :logo_file
validates :primary_color, format: { with: HEX_COLOR }, allow_blank: true
validates :secondary_color, format: { with: HEX_COLOR }, allow_blank: true
end
def effective_primary_color
primary_color.presence || default_primary_color
end
def effective_secondary_color
secondary_color.presence || default_secondary_color
end
def effective_logo_url
if logo_file.attached?
Rails.application.routes.url_helpers.rails_blob_path(logo_file, only_path: true)
elsif logo_url.present?
logo_url
else
branding_parent&.effective_logo_url
end
end
private
def default_primary_color
"#e53935"
end
def default_secondary_color
"#ffffff"
end
def branding_parent
nil
end
end