Add portrait settings support to school creation and update related API and UI components. Enhance error handling for invalid presets and ensure proper cloning of settings. Update tests to validate new functionality.
This commit is contained in:
@@ -128,6 +128,7 @@ Welcome не трогаем, версию не бампим. Глобальны
|
||||
|
||||
- пауза, скорость, пропуск пустого времени — кадр сокета игнорируется (не закрывает соединение);
|
||||
- удалить, нанять, назначить, сменить правила, закрепить урок — HTTP `403` `not-owner`;
|
||||
- генерировать портреты — **можно**: пресеты лежат на школе, модель одна и та же;
|
||||
- видеть вкладку «Управление» — клиент её не монтирует. Карта и люди — да, карточка — да.
|
||||
|
||||
Хозяин, который смотрит свою, ничего не теряет. Несколько гостей на одну школу — несколько
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
`others` — чужие и бесхозные (`owner` имя или `null`). Карточка школы несёт `mine`
|
||||
- [ ] Welcome.`MaxSchools` — слоты игрока (байт тот же, смысл новый)
|
||||
- [ ] Мутации чужой — HTTP `403` `not-owner`. Бесхозную может удалить любой залогиненный.
|
||||
`OpenSchool` — всем с сессией. Пауза / скорость / пропуск от гостя до работника не доходят
|
||||
`OpenSchool` — всем с сессией. Пауза / скорость / пропуск от гостя до работника не доходят.
|
||||
**Исключение:** `POST .../portrait` — гость генерирует теми же пресетами школы; это не управление
|
||||
- [ ] Меню: блок «Мои» и блок «Чужие». У бесхозной в чужих — удалить, у чужой с хозяином — нет
|
||||
- [ ] Внутри чужой школы нет вкладки «Управление» и нет кнопок часов (пауза, скорость, пропуск).
|
||||
Карта и люди остаются
|
||||
|
||||
+13
-6
@@ -164,7 +164,8 @@ Body:
|
||||
"map": null,
|
||||
"countryId": "Russia",
|
||||
"nativeLanguage": null,
|
||||
"seed": null
|
||||
"seed": null,
|
||||
"portraitSettings": null
|
||||
}
|
||||
```
|
||||
|
||||
@@ -178,6 +179,10 @@ the same catalog. Omit `map` (or send `null`) to use that pack set's default lay
|
||||
one from the school seed. An id that is not in the country returns `400` `unknown-native-language`.
|
||||
`seed` is an optional integer. Send it to reproduce a known school; omit it (or send `null`) and
|
||||
the server rolls one. Existing saves keep the seed already stored in the people file.
|
||||
`portraitSettings` is the SwarmUI preset file for **this** school (same shape as
|
||||
`GET /api/settings/swarmui`). Omit it (or send `null`) to copy the server template at create.
|
||||
Invalid presets return `400` `invalid-portrait-settings`. Generation later uses this copy, not
|
||||
the global file, so a guest watching the school draws with the same model.
|
||||
|
||||
| Status | Meaning |
|
||||
| --- | --- |
|
||||
@@ -191,6 +196,7 @@ the server rolls one. Existing saves keep the seed already stored in the people
|
||||
| `400` `invalid-catalog` | The selected packs could not be loaded. |
|
||||
| `400` `unknown-country` | `countryId` is not a placeable `CountryDef` in those packs. |
|
||||
| `400` `unknown-native-language` | `nativeLanguage` is not in that country's `nativeLanguages`. |
|
||||
| `400` `invalid-portrait-settings` | `portraitSettings` failed validation (empty presets, bad age rule, out of range). |
|
||||
| `409` `school-limit-reached` | `maxSchools` schools already exist. |
|
||||
|
||||
Failures are RFC 7807 problem details with an extra `code` field — that is what the UI switches on.
|
||||
@@ -470,14 +476,15 @@ so the client can disable generate buttons and show reachability without trying
|
||||
|
||||
### `GET /api/settings/swarmui`
|
||||
|
||||
Returns the editable SwarmUI preset file (`swarmui.json`): named presets (model, steps, sampler,
|
||||
LoRA lists, per-kind sizes/prompts), `activePresetId` and `ageRules` mapping age bands to presets.
|
||||
Portrait generation resolves the preset from the person's age before building the prompt.
|
||||
Returns the **default** SwarmUI preset template (`swarmui.json`): named presets (model, steps,
|
||||
sampler, LoRA lists, per-kind sizes/prompts), `activePresetId` and `ageRules`. A new school copies
|
||||
this into its save as `portraitSettings`. Living schools generate from that copy, not from this
|
||||
file.
|
||||
|
||||
### `PUT /api/settings/swarmui`
|
||||
|
||||
Replaces the preset file after validation. Invalid preset ids, age rules or numeric ranges return
|
||||
`400` `invalid-body`. Changes apply immediately to new portrait generations.
|
||||
Replaces the default template after validation. Invalid preset ids, age rules or numeric ranges
|
||||
return `400` `invalid-body`. Already-created schools keep the copy they were created with.
|
||||
|
||||
### `GET /api/settings/swarmui/discovery`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user