Billing Stripe, link regia mobile e staff solo trasmissione.
Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,51 @@ class User < ApplicationRecord
|
||||
Team.where(id: staff_ids).or(Team.where(id: owner_ids))
|
||||
end
|
||||
|
||||
# Squadre da cui l'utente può programmare partite e avviare lo streaming (app).
|
||||
def streamable_teams
|
||||
manageable_teams.includes(:club).select { |team| can_stream_for?(team) }
|
||||
end
|
||||
|
||||
def club_admin?(club)
|
||||
club&.owned_by?(self)
|
||||
end
|
||||
|
||||
def can_schedule_for?(team)
|
||||
return true if team.club&.owned_by?(self)
|
||||
|
||||
membership = user_teams.find_by(team: team)
|
||||
return false if membership&.staff_kind.blank?
|
||||
|
||||
membership.staff_kind == "transmission"
|
||||
end
|
||||
|
||||
def schedulable_teams_for(club)
|
||||
teams = club.teams.order(:name).to_a
|
||||
return teams if club.owned_by?(self)
|
||||
|
||||
teams.select { |team| can_schedule_for?(team) }
|
||||
end
|
||||
|
||||
def can_stream_for?(team)
|
||||
return true if team.club&.owned_by?(self)
|
||||
|
||||
membership = user_teams.find_by(team: team)
|
||||
return false if membership&.staff_kind.blank?
|
||||
|
||||
return true if membership.staff_kind == "transmission"
|
||||
|
||||
Teams::StaffCoverage.new(team).covers_both_roles?(membership)
|
||||
end
|
||||
|
||||
def staff_role_for(team)
|
||||
return "owner" if team.club&.owned_by?(self)
|
||||
|
||||
membership = user_teams.find_by(team: team)
|
||||
return nil unless membership&.staff_kind.present?
|
||||
|
||||
"transmission"
|
||||
end
|
||||
|
||||
def primary_club
|
||||
owned_clubs.order(:created_at).first
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user