diff --git a/app/belki/api.py b/app/belki/api.py index ee25273..36e6d1c 100644 --- a/app/belki/api.py +++ b/app/belki/api.py @@ -86,13 +86,13 @@ def resolve_identity_payload(payload: dict[str, Any]) -> dict[str, Any]: if not name and raw_id in (None, ""): raise ApiError("Укажите имя или ID персонажа") if isinstance(raw_id, bool): - raise ApiError("ID персонажа должно быть числом") + raise ApiError("ID персонажа должен быть числом") try: character_id = int(raw_id) if raw_id not in (None, "") else None except (TypeError, ValueError) as exc: - raise ApiError("ID персонажа должно быть числом") from exc + raise ApiError("ID персонажа должен быть числом") from exc if character_id is not None and character_id <= 0: - raise ApiError("ID персонажа должно быть положительным") + raise ApiError("ID персонажа должен быть положительным") directory = _identity_directory() identity = directory.resolve(name=name, character_id=character_id) if identity: @@ -124,12 +124,13 @@ def _int(payload: dict[str, Any], key: str) -> int: def _int_value(value: Any, label: str) -> int: """Convert one JSON integer while refusing Python's boolean coercion.""" + verb = "должен" if label.startswith("ID ") else "должно" if isinstance(value, bool): - raise ApiError(f"{label} должно быть числом") + raise ApiError(f"{label} {verb} быть числом") try: return int(value) except (TypeError, ValueError) as exc: - raise ApiError(f"{label} должно быть числом") from exc + raise ApiError(f"{label} {verb} быть числом") from exc def calculate_payload(payload: dict[str, Any]) -> dict[str, Any]: diff --git a/app/belki/applications.py b/app/belki/applications.py index 39a78f6..1206ff2 100644 --- a/app/belki/applications.py +++ b/app/belki/applications.py @@ -29,14 +29,15 @@ class ApplicationError(ValueError): def _positive_id(value: Any, label: str) -> int: + verb = "должен" if label.startswith("ID ") else "должно" if isinstance(value, bool): - raise ApplicationError(f"{label} должно быть числом") + raise ApplicationError(f"{label} {verb} быть числом") try: result = int(value) except (TypeError, ValueError) as exc: - raise ApplicationError(f"{label} должно быть числом") from exc + raise ApplicationError(f"{label} {verb} быть числом") from exc if result <= 0: - raise ApplicationError(f"{label} должно быть положительным") + raise ApplicationError(f"{label} {verb} быть положительным") return result @@ -243,7 +244,7 @@ class ApplicationStore: def accept(self, application_id: int) -> dict[str, Any] | None: if application_id <= 0: - raise ApplicationError("ID заявки должно быть положительным") + raise ApplicationError("ID заявки должен быть положительным") if self.database_url.startswith(("postgres://", "postgresql://")): with self._psycopg.connect(self.database_url) as connection: row = connection.execute("""UPDATE belki_applications SET status = 'accepted', reviewed_at = NOW() diff --git a/app/belki/history.py b/app/belki/history.py index e8a6f9e..bcbffc3 100644 --- a/app/belki/history.py +++ b/app/belki/history.py @@ -179,7 +179,7 @@ class CalculationStore: def delete_calculation(self, calculation_id: int) -> bool: """Delete one history row and report whether it existed.""" if isinstance(calculation_id, bool) or not isinstance(calculation_id, int) or calculation_id <= 0: - raise ValueError("ID записи должно быть положительным целым числом") + raise ValueError("ID записи должен быть положительным целым числом") if self.database_url.startswith(("postgres://", "postgresql://")): with self._psycopg.connect(self.database_url) as connection: row = connection.execute( diff --git a/structure_and_data.md b/structure_and_data.md index daa2224..c40ca25 100644 --- a/structure_and_data.md +++ b/structure_and_data.md @@ -75,6 +75,7 @@ - 2026-08-25: coaching sessions now validate a real calendar date in `ДД.ММ` form before any calculation or persistence; free-form dates remain accepted after parser normalization. - 2026-08-25: coaching and training reports reject a repeated participant ID, including an escort submitted as their own kitten, so duplicate input cannot inflate a result. - 2026-08-25: direct domain calls with non-text participant names now return the same clear validation errors as API and VK input, rather than an implementation-level attribute error. +- 2026-08-25: corrected Russian grammatical agreement in user-facing ID validation messages (`ID … должен быть`), including shared application and API helpers. - 2026-08-25: one-line VK/web recognition now gives explicit role labels priority over position. `сопровождающий`/`наставник`/`учитель` identify the escort, while `ученик`/`котёнок`/`бельчонок`/`подопечный` identify the ward; unlabeled pairs retain the original order-based fallback. - 2026-08-25: a self-sufficiency marker directly beside a labelled ward now belongs to that ward, so one natural line can describe different statuses for several kittens. - 2026-08-25: corrected Russian UX copy in the VK help and attachment flow; the web identity hint now accurately says that a manually completed pair applies only to the current calculation. diff --git a/tests/test_applications.py b/tests/test_applications.py index 7d64a79..ea1f6f3 100644 --- a/tests/test_applications.py +++ b/tests/test_applications.py @@ -37,7 +37,7 @@ class ApplicationTests(unittest.TestCase): }) def test_application_rejects_boolean_character_and_feather_ids(self) -> None: - with self.assertRaisesRegex(ApplicationError, "ID персонажа должно быть числом"): + with self.assertRaisesRegex(ApplicationError, "ID персонажа должен быть числом"): validate_application({"type": "kitten", "name": "Муся", "character_id": True, "attachments": [{"url": "https://img.example.test/a.jpg"}]}) with self.assertRaisesRegex(ApplicationError, "Количество перьев должно быть числом"): validate_application({