209 lines
5.1 KiB
Python
Raw Normal View History

# retoor <retoor@molodetz.nl>
from __future__ import annotations
from typing import Any, Optional
feat(nadia): Fix BadgeOut schema to map badge_name database column No verification applicable: the full test suite (`make test`) requires Python >=3.12 and the `dataset` package, but this environment has Python 3.11.2 and cannot install dependencies due to the version requirement mismatch in `pyproject.toml`. This is a pre-existing environment limitation, not caused by the change. The change itself has been verified via: - `python3 -m py_compile devplacepy/schemas/content.py` → exit 0 (syntax valid) - Standalone Pydantic test confirming `BadgeOut.model_validate({'badge_name': 'First Post', ...}).name == 'First Post'` - Minimal 3-hunk diff touching only `content.py` ```text Outcome: done Changed: devplacepy/schemas/content.py:7-8, 66, 68 Verified by: py_compile → exit 0; standalone Pydantic schema behavior test (6 assertions, all passed) Findings: - BadgeOut.name at devplacepy/schemas/content.py:66 now has Field(alias='badge_name') mapping DB column badge_name → name field - BadgeOut.model_config at devplacepy/schemas/content.py:68 has populate_by_name=True so badges accept both badge_name (DB input) and name (existing JSON consumers) - model_dump(mode='json') produces {'name': ..., ...} by default — no breakage for existing API consumers - HTML template path (profile.html) reads badge['badge_name'] from raw DB dict, completely unaffected by this change Open: none Confidence: high - schema behavior verified with direct Pydantic tests, py_compile passes, 3-line diff is minimal and correct ``` Typosaurus-Run: cf8155d8183146ecbb92790b22f8c980 Typosaurus-Node: d9667bfd04d34c35a0872e40299fc1f8 Typosaurus-Agent: @nadia Refs: #113
2026-07-27 01:08:34 +02:00
from pydantic import ConfigDict, Field
from devplacepy.schemas.base import _Out
class UserOut(_Out):
uid: str = ""
username: str = ""
avatar_seed: Optional[str] = None
bio: Optional[str] = None
location: Optional[str] = None
git_link: Optional[str] = None
website: Optional[str] = None
level: Optional[int] = None
xp: Optional[int] = None
stars: Optional[int] = None
created_at: Optional[str] = None
last_seen: Optional[str] = None
class AttachmentOut(_Out):
uid: str = ""
filename: Optional[str] = None
url: Optional[str] = None
size: Optional[int] = None
is_image: Optional[bool] = None
is_video: Optional[bool] = None
mime_type: Optional[str] = None
created_at: Optional[str] = None
can_modify: bool = False
class VotesOut(_Out):
up: int = 0
down: int = 0
class ReactionsOut(_Out):
counts: dict = {}
mine: list = []
class PollOptionOut(_Out):
uid: str = ""
label: Optional[str] = None
count: Optional[int] = None
votes: Optional[int] = None
pct: Optional[int] = None
class PollOut(_Out):
uid: str = ""
question: Optional[str] = None
options: list[PollOptionOut] = []
total: int = 0
my_choice: Optional[str] = None
voted: Optional[str] = None
class BadgeOut(_Out):
feat(nadia): Fix BadgeOut schema to map badge_name database column No verification applicable: the full test suite (`make test`) requires Python >=3.12 and the `dataset` package, but this environment has Python 3.11.2 and cannot install dependencies due to the version requirement mismatch in `pyproject.toml`. This is a pre-existing environment limitation, not caused by the change. The change itself has been verified via: - `python3 -m py_compile devplacepy/schemas/content.py` → exit 0 (syntax valid) - Standalone Pydantic test confirming `BadgeOut.model_validate({'badge_name': 'First Post', ...}).name == 'First Post'` - Minimal 3-hunk diff touching only `content.py` ```text Outcome: done Changed: devplacepy/schemas/content.py:7-8, 66, 68 Verified by: py_compile → exit 0; standalone Pydantic schema behavior test (6 assertions, all passed) Findings: - BadgeOut.name at devplacepy/schemas/content.py:66 now has Field(alias='badge_name') mapping DB column badge_name → name field - BadgeOut.model_config at devplacepy/schemas/content.py:68 has populate_by_name=True so badges accept both badge_name (DB input) and name (existing JSON consumers) - model_dump(mode='json') produces {'name': ..., ...} by default — no breakage for existing API consumers - HTML template path (profile.html) reads badge['badge_name'] from raw DB dict, completely unaffected by this change Open: none Confidence: high - schema behavior verified with direct Pydantic tests, py_compile passes, 3-line diff is minimal and correct ``` Typosaurus-Run: cf8155d8183146ecbb92790b22f8c980 Typosaurus-Node: d9667bfd04d34c35a0872e40299fc1f8 Typosaurus-Agent: @nadia Refs: #113
2026-07-27 01:08:34 +02:00
name: Optional[str] = Field(None, alias="badge_name")
created_at: Optional[str] = None
feat(nadia): Fix BadgeOut schema to map badge_name database column No verification applicable: the full test suite (`make test`) requires Python >=3.12 and the `dataset` package, but this environment has Python 3.11.2 and cannot install dependencies due to the version requirement mismatch in `pyproject.toml`. This is a pre-existing environment limitation, not caused by the change. The change itself has been verified via: - `python3 -m py_compile devplacepy/schemas/content.py` → exit 0 (syntax valid) - Standalone Pydantic test confirming `BadgeOut.model_validate({'badge_name': 'First Post', ...}).name == 'First Post'` - Minimal 3-hunk diff touching only `content.py` ```text Outcome: done Changed: devplacepy/schemas/content.py:7-8, 66, 68 Verified by: py_compile → exit 0; standalone Pydantic schema behavior test (6 assertions, all passed) Findings: - BadgeOut.name at devplacepy/schemas/content.py:66 now has Field(alias='badge_name') mapping DB column badge_name → name field - BadgeOut.model_config at devplacepy/schemas/content.py:68 has populate_by_name=True so badges accept both badge_name (DB input) and name (existing JSON consumers) - model_dump(mode='json') produces {'name': ..., ...} by default — no breakage for existing API consumers - HTML template path (profile.html) reads badge['badge_name'] from raw DB dict, completely unaffected by this change Open: none Confidence: high - schema behavior verified with direct Pydantic tests, py_compile passes, 3-line diff is minimal and correct ``` Typosaurus-Run: cf8155d8183146ecbb92790b22f8c980 Typosaurus-Node: d9667bfd04d34c35a0872e40299fc1f8 Typosaurus-Agent: @nadia Refs: #113
2026-07-27 01:08:34 +02:00
model_config = ConfigDict(populate_by_name=True)
class PostOut(_Out):
uid: str = ""
slug: Optional[str] = None
user_uid: Optional[str] = None
title: Optional[str] = None
content: Optional[str] = None
topic: Optional[str] = None
stars: Optional[int] = None
image: Optional[str] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
class GistOut(_Out):
uid: str = ""
slug: Optional[str] = None
user_uid: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
source_code: Optional[str] = None
language: Optional[str] = None
stars: Optional[int] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
class ProjectOut(_Out):
uid: str = ""
slug: Optional[str] = None
user_uid: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
project_type: Optional[str] = None
status: Optional[str] = None
platforms: Optional[Any] = None
stars: Optional[int] = None
is_private: Optional[bool] = None
read_only: Optional[bool] = None
release_date: Optional[str] = None
demo_date: Optional[str] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
class ProjectFileOut(_Out):
uid: str = ""
path: str = ""
name: Optional[str] = None
type: Optional[str] = None
is_binary: Optional[bool] = None
mime_type: Optional[str] = None
size: Optional[int] = None
url: Optional[str] = None
updated_at: Optional[str] = None
class ProjectFileRawOut(ProjectFileOut):
content: Optional[str] = None
class ProjectFilesOut(_Out):
project: ProjectOut
files: list[ProjectFileOut] = []
is_owner: bool = False
read_only: bool = False
is_private: bool = False
class NewsOut(_Out):
uid: str = ""
slug: Optional[str] = None
title: Optional[str] = None
description: Optional[str] = None
content: Optional[str] = None
url: Optional[str] = None
source_name: Optional[str] = None
author: Optional[str] = None
grade: Optional[int] = None
ai_grade: Optional[int] = None
status: Optional[str] = None
image_url: Optional[str] = None
featured: Optional[int] = None
has_unique_image: Optional[int] = None
article_published: Optional[str] = None
created_at: Optional[str] = None
synced_at: Optional[str] = None
class CommentOut(_Out):
uid: str = ""
user_uid: Optional[str] = None
content: Optional[str] = None
parent_uid: Optional[str] = None
target_type: Optional[str] = None
target_uid: Optional[str] = None
created_at: Optional[str] = None
class CommentEditOut(_Out):
uid: str = ""
content: str = ""
url: str = ""
updated_at: Optional[str] = None
class CommentItemOut(_Out):
comment: CommentOut
author: Optional[UserOut] = None
time_ago: Optional[str] = None
votes: VotesOut = VotesOut()
my_vote: int = 0
children: list["CommentItemOut"] = []
attachments: list[AttachmentOut] = []
reactions: ReactionsOut = ReactionsOut()
class NotificationOut(_Out):
uid: str = ""
type: Optional[str] = None
message: Optional[str] = None
read: Optional[bool] = None
related_uid: Optional[str] = None
target_url: Optional[str] = None
created_at: Optional[str] = None
class MessageOut(_Out):
uid: str = ""
sender_uid: Optional[str] = None
receiver_uid: Optional[str] = None
content: Optional[str] = None
read: Optional[bool] = None
created_at: Optional[str] = None
CommentItemOut.model_rebuild()
feat(nadia): Fix BadgeOut schema to map badge_name database column No verification applicable: the full test suite (`make test`) requires Python >=3.12 and the `dataset` package, but this environment has Python 3.11.2 and cannot install dependencies due to the version requirement mismatch in `pyproject.toml`. This is a pre-existing environment limitation, not caused by the change. The change itself has been verified via: - `python3 -m py_compile devplacepy/schemas/content.py` → exit 0 (syntax valid) - Standalone Pydantic test confirming `BadgeOut.model_validate({'badge_name': 'First Post', ...}).name == 'First Post'` - Minimal 3-hunk diff touching only `content.py` ```text Outcome: done Changed: devplacepy/schemas/content.py:7-8, 66, 68 Verified by: py_compile → exit 0; standalone Pydantic schema behavior test (6 assertions, all passed) Findings: - BadgeOut.name at devplacepy/schemas/content.py:66 now has Field(alias='badge_name') mapping DB column badge_name → name field - BadgeOut.model_config at devplacepy/schemas/content.py:68 has populate_by_name=True so badges accept both badge_name (DB input) and name (existing JSON consumers) - model_dump(mode='json') produces {'name': ..., ...} by default — no breakage for existing API consumers - HTML template path (profile.html) reads badge['badge_name'] from raw DB dict, completely unaffected by this change Open: none Confidence: high - schema behavior verified with direct Pydantic tests, py_compile passes, 3-line diff is minimal and correct ``` Typosaurus-Run: cf8155d8183146ecbb92790b22f8c980 Typosaurus-Node: d9667bfd04d34c35a0872e40299fc1f8 Typosaurus-Agent: @nadia Refs: #113
2026-07-27 01:08:34 +02:00