BUILD129 — три настраиваемых цвета команд

This commit is contained in:
2026-09-10 11:05:16 +03:00
parent f4f80d7837
commit a9278b5251
8 changed files with 243 additions and 62 deletions

View File

@@ -609,6 +609,16 @@ class HockeyDataService:
"city_ru": team.city_ru,
"city_en": team.city_en,
"color_hex": team.color_hex,
"color_enabled": bool(team.color_enabled),
"color_2_hex": team.color_2_hex,
"color_2_enabled": bool(team.color_2_enabled),
"color_3_hex": team.color_3_hex,
"color_3_enabled": bool(team.color_3_enabled),
"colors": [
{"index": 1, "hex": team.color_hex, "enabled": bool(team.color_enabled)},
{"index": 2, "hex": team.color_2_hex, "enabled": bool(team.color_2_enabled)},
{"index": 3, "hex": team.color_3_hex, "enabled": bool(team.color_3_enabled)},
],
"logo_url": team.logo_url,
"source": membership.source,
"active": bool(membership.active),
@@ -756,8 +766,17 @@ class HockeyDataService:
if field in payload and payload[field] is not None:
setattr(team, field, str(payload[field]).strip())
if "color_hex" in payload and payload["color_hex"] is not None:
team.color_hex = normalise_team_color_hex(payload["color_hex"])
color_fields = (
("color_hex", "color_enabled"),
("color_2_hex", "color_2_enabled"),
("color_3_hex", "color_3_enabled"),
)
for color_field, enabled_field in color_fields:
if color_field in payload and payload[color_field] is not None:
setattr(team, color_field, normalise_team_color_hex(payload[color_field]))
if enabled_field in payload:
color_value = str(getattr(team, color_field, "") or "").strip()
setattr(team, enabled_field, bool(payload.get(enabled_field)) and bool(color_value))
if not (team.name_ru or team.name_en):
raise ValueError("Укажите название команды на русском или английском")