Introduce architettura multi-sport con catalogo, engine scoring e overlay.
Catalogo sport in YAML, board implicito, engine per volley/basket/timed/racket/timer/generic, regia e app Android allineate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,10 +21,11 @@ module Api
|
||||
}, status: :unprocessable_entity
|
||||
end
|
||||
|
||||
club = Club.create!(name: team_params[:name], sport: team_params[:sport] || "volleyball",
|
||||
sport_key = Sports::Catalog.normalize_key(team_params[:sport_key] || team_params[:sport] || "pallavolo")
|
||||
club = Club.create!(name: team_params[:name], sport: sport_key,
|
||||
primary_color: "#e53935", secondary_color: "#ffffff")
|
||||
ClubMembership.create!(user: current_user, club: club, role: "owner")
|
||||
team = club.teams.create!(name: team_params[:name], sport: club.sport)
|
||||
team = club.teams.create!(name: team_params[:name], sport_key: sport_key)
|
||||
Billing::AssignPlan.call(club: club, plan_slug: "free")
|
||||
render json: team_json(team), status: :created
|
||||
end
|
||||
@@ -74,7 +75,11 @@ module Api
|
||||
private
|
||||
|
||||
def team_params
|
||||
p = params.require(:team).permit(:name, :sport, :logo_url, :primary_color, :secondary_color)
|
||||
p = params.require(:team).permit(:name, :sport, :sport_key, :logo_url, :primary_color, :secondary_color)
|
||||
if p[:sport].present? && p[:sport_key].blank?
|
||||
p[:sport_key] = p.delete(:sport)
|
||||
end
|
||||
p
|
||||
if p[:primary_color].present?
|
||||
p[:primary_color] = normalize_hex_color(p[:primary_color], p[:primary_color])
|
||||
end
|
||||
@@ -96,7 +101,10 @@ module Api
|
||||
data = {
|
||||
id: team.id,
|
||||
name: team.name,
|
||||
sport: team.sport,
|
||||
sport: team.sport_key,
|
||||
sport_key: team.sport_key,
|
||||
sport_label: team.sport_label,
|
||||
board_type: team.effective_board_type,
|
||||
logo_url: api_absolute_url(team.effective_logo_url),
|
||||
primary_color: team.effective_primary_color,
|
||||
secondary_color: team.effective_secondary_color,
|
||||
|
||||
Reference in New Issue
Block a user