fix: add UTC timezone indicator to all datetime serialization
Database stores times in UTC but serialized without timezone info, causing frontend to misinterpret as local time. Now all datetime fields include 'Z' suffix to indicate UTC, enabling proper timezone conversion in the browser. - Add UTCDatetimeBaseModel base class for Pydantic schemas - Update model to_dict() methods to append 'Z' suffix - Affects: tasks, users, sessions, audit logs, translations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ from typing import Optional
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.schemas.base import UTCDatetimeBaseModel
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
"""Login request schema"""
|
||||
@@ -58,7 +60,7 @@ class TokenData(BaseModel):
|
||||
session_id: Optional[int] = None
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
class UserResponse(UTCDatetimeBaseModel):
|
||||
"""User response schema"""
|
||||
id: int
|
||||
email: str
|
||||
@@ -66,9 +68,3 @@ class UserResponse(BaseModel):
|
||||
created_at: Optional[datetime] = None
|
||||
last_login: Optional[datetime] = None
|
||||
is_active: bool = True
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
json_encoders = {
|
||||
datetime: lambda v: v.isoformat() if v else None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user