New web ui

This commit is contained in:
nyan404 committed 2026-08-17 02:31:18 +03:00
1 parent a360fd9c63
commit caee27c3ea
11 files changed
+248 -16

No files matched your search

+2 -2
View File
@@ -87,8 +87,8 @@ class CoachingSession:
raise ValueError("Некорректный статус самостоятельности")
statuses = (self.kitten_independence,) + tuple(independence for _, _, independence in self.extra_kittens)
nonself_count = sum(status == "несамостоятельно" for status in statuses)
if self.skill == "ЗУ" and len(set(statuses)) > 1:
raise ValueError("Для ЗУ все котята в одном отчёте должны иметь одинаковый статус")
if self.skill == "ЗУ" and any(s != "самостоятельно" for s in statuses):
raise ValueError("Для ЗУ все котята должны быть самостоятельными")
if self.skill == "ЛУ" and nonself_count > 1:
raise ValueError("Для ЛУ допускается только один несамостоятельный котёнок")
+6
View File
@@ -55,6 +55,12 @@ class ImageHostClient:
body = response.read()
content_type = response.headers.get_content_type() or "image/jpeg"
file_name = f"vk-{photo.get('owner_id', 'photo')}-{photo.get('id', 'upload')}.jpg"
return self.upload_bytes(body, file_name, content_type)
def upload_bytes(self, body: bytes, file_name: str, content_type: str = "image/jpeg") -> str | None:
"""Загружает произвольный файл на image-host и возвращает прямую ссылку."""
if not self.api_url or not body:
return None
initiate = self._request_json(
"/api/uploads/initiate",
{
+2 -2
View File
@@ -96,8 +96,8 @@ def _extra_kittens(value: str) -> tuple[tuple[str, int, str], ...]:
def _validate_independence(skill: str, primary: str, extras: tuple[tuple[str, int, str], ...] | list[tuple[str, int, str]]) -> None:
statuses = (primary,) + tuple(independence for _, _, independence in extras)
if skill == "ЗУ" and len(set(statuses)) > 1:
raise ValueError("Для ЗУ все котята в одном отчёте должны иметь одинаковый статус")
if skill == "ЗУ" and any(s != "самостоятельно" for s in statuses):
raise ValueError("Для ЗУ все котята должны быть самостоятельными")
if skill == "ЛУ" and sum(status == "несамостоятельно" for status in statuses) > 1:
raise ValueError("Для ЛУ допускается только один несамостоятельный котёнок")