fix(domain): bound public report input sizes
This commit is contained in:
1 parent
1c2bfa9594
commit
c0a6f6286e
7 files changed
+39
-4
No files matched your search
@@ -15,6 +15,7 @@ from urllib.parse import urlencode
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from .api import ApiError, calculate_payload
|
||||
from .domain import MAX_COACHING_KITTENS
|
||||
from .history import CalculationStore
|
||||
from .image_host import ImageHostClient
|
||||
from .identity import Identity, IdentityDirectory
|
||||
@@ -163,11 +164,15 @@ def _extra_kittens(value: str) -> tuple[tuple[str, int, str], ...]:
|
||||
item = item[:status.start()].strip()
|
||||
name, kitten_id = _person(item)
|
||||
result.append((name, kitten_id, independence))
|
||||
if len(result) >= MAX_COACHING_KITTENS:
|
||||
raise ValueError(f"Можно добавить не более {MAX_COACHING_KITTENS - 1} дополнительных котят")
|
||||
return tuple(result)
|
||||
|
||||
|
||||
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 len(statuses) > MAX_COACHING_KITTENS:
|
||||
raise ValueError(f"В одном заходе может участвовать не более {MAX_COACHING_KITTENS} котят")
|
||||
if skill == "ЗУ" and any(s != "самостоятельно" for s in statuses):
|
||||
raise ValueError("Для ЗУ все котята должны быть самостоятельными")
|
||||
if skill == "ЛУ" and sum(status == "несамостоятельно" for status in statuses) > 1:
|
||||
|
||||
Reference in new issue
Block a user