initial commit

This commit is contained in:
2025-11-20 14:06:59 -05:00
commit cb0f972a5f
77 changed files with 11579 additions and 0 deletions

39
models/child.py Normal file
View File

@@ -0,0 +1,39 @@
from dataclasses import dataclass, field
import uuid
@dataclass
class Child:
name: str
age: int | None = None
tasks: list[str] = field(default_factory=list)
rewards: list[str] = field(default_factory=list)
points: int = 0
image_id: str | None = None
id: str | None = None
def __post_init__(self):
if self.id is None:
self.id = str(uuid.uuid4())
@classmethod
def from_dict(cls, d: dict):
return cls(
id=d.get('id'),
name=d.get('name'),
age=d.get('age'),
tasks=d.get('tasks', []),
rewards=d.get('rewards', []),
points=d.get('points', 0),
image_id=d.get('image_id')
)
def to_dict(self):
return {
'id': self.id,
'name': self.name,
'age': self.age,
'tasks': self.tasks,
'rewards': self.rewards,
'points': self.points,
'image_id': self.image_id
}

30
models/image.py Normal file
View File

@@ -0,0 +1,30 @@
from dataclasses import dataclass
import uuid
@dataclass
class Image:
type: int
extension: str
permanent: bool = False
id: str | None = None
def __post_init__(self):
if self.id is None:
self.id = str(uuid.uuid4())
@classmethod
def from_dict(cls, d: dict):
return cls(
id=d.get('id'),
type=d.get('type'),
permanent=d.get('permanent', False),
extension=d.get('extension')
)
def to_dict(self):
return {
'id': self.id,
'type': self.type,
'permanent': self.permanent,
'extension': self.extension
}

33
models/reward.py Normal file
View File

@@ -0,0 +1,33 @@
from dataclasses import dataclass
import uuid
@dataclass
class Reward:
name: str
description: str
cost: int
image_id: str | None = None
id: str | None = None
def __post_init__(self):
if self.id is None:
self.id = str(uuid.uuid4())
@classmethod
def from_dict(cls, d: dict):
return cls(
id=d.get('id'),
name=d.get('name'),
description=d.get('description'),
cost=d.get('cost', 0),
image_id=d.get('image_id')
)
def to_dict(self):
return {
'id': self.id,
'name': self.name,
'description': self.description,
'cost': self.cost,
'image_id': self.image_id
}

33
models/task.py Normal file
View File

@@ -0,0 +1,33 @@
from dataclasses import dataclass
import uuid
@dataclass
class Task:
name: str
points: int
is_good: bool
image_id: str | None = None
id: str | None = None
def __post_init__(self):
if self.id is None:
self.id = str(uuid.uuid4())
@classmethod
def from_dict(cls, d: dict):
return cls(
id=d.get('id'),
name=d.get('name'),
points=d.get('points', 0),
is_good=d.get('is_good', True),
image_id=d.get('image_id')
)
def to_dict(self):
return {
'id': self.id,
'name': self.name,
'points': self.points,
'is_good': self.is_good,
'image_id': self.image_id
}