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:
@@ -5,8 +5,21 @@ class User < ApplicationRecord
|
||||
|
||||
has_many :user_teams, dependent: :destroy
|
||||
has_many :teams, through: :user_teams
|
||||
has_many :club_memberships, dependent: :destroy
|
||||
has_many :clubs, through: :club_memberships
|
||||
has_many :owned_clubs, -> { where(club_memberships: { role: "owner" }) }, through: :club_memberships, source: :club
|
||||
has_many :stream_sessions, dependent: :nullify
|
||||
|
||||
def manageable_teams
|
||||
staff_ids = teams.select(:id)
|
||||
owner_ids = Team.where(club_id: owned_clubs.select(:id)).select(:id)
|
||||
Team.where(id: staff_ids).or(Team.where(id: owner_ids))
|
||||
end
|
||||
|
||||
def primary_club
|
||||
owned_clubs.order(:created_at).first
|
||||
end
|
||||
|
||||
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validates :name, presence: true
|
||||
validates :role, inclusion: { in: ROLES }
|
||||
|
||||
Reference in New Issue
Block a user