Files
grateful-journal/backend/models.py
2026-03-04 12:34:12 +05:30

85 lines
1.8 KiB
Python

from pydantic import BaseModel, Field # type: ignore
from datetime import datetime
from typing import Optional, List
from enum import Enum
# ========== User Models ==========
class UserCreate(BaseModel):
email: str
displayName: Optional[str] = None
photoURL: Optional[str] = None
class UserUpdate(BaseModel):
displayName: Optional[str] = None
photoURL: Optional[str] = None
theme: Optional[str] = None
class User(BaseModel):
id: str
email: str
displayName: Optional[str] = None
photoURL: Optional[str] = None
createdAt: datetime
updatedAt: datetime
theme: Optional[str] = "light"
# ========== Journal Entry Models ==========
class MoodEnum(str, Enum):
happy = "happy"
sad = "sad"
neutral = "neutral"
anxious = "anxious"
grateful = "grateful"
class JournalEntryCreate(BaseModel):
title: str
content: str
mood: Optional[MoodEnum] = None
tags: Optional[List[str]] = None
isPublic: Optional[bool] = False
class JournalEntryUpdate(BaseModel):
title: Optional[str] = None
content: Optional[str] = None
mood: Optional[MoodEnum] = None
tags: Optional[List[str]] = None
isPublic: Optional[bool] = None
class JournalEntry(BaseModel):
id: str
userId: str
title: str
content: str
mood: Optional[MoodEnum] = None
tags: Optional[List[str]] = None
isPublic: bool = False
createdAt: datetime
updatedAt: datetime
# ========== Settings Models ==========
class UserSettingsUpdate(BaseModel):
notifications: Optional[bool] = None
emailNotifications: Optional[bool] = None
theme: Optional[str] = None
language: Optional[str] = None
class UserSettings(BaseModel):
userId: str
notifications: bool = True
emailNotifications: bool = False
theme: str = "light"
language: str = "en"
updatedAt: datetime