from __future__ import annotations from dataclasses import dataclass, field from datetime import datetime from typing import TYPE_CHECKING, Optional from uuid import UUID, uuid4 if TYPE_CHECKING: from backend.model.tribe import Tribe @dataclass class Student: name: str tribe: Tribe id: str = field(default_factory=lambda: str(uuid4())) def __post_init__(self) -> None: self.tribe.register_student(self) def __eq__(self, other: object) -> bool: if isinstance(other, Student): return self.id == other.id return False def __hash__(self) -> int: return hash(self.id) def to_tuple(self) -> tuple: return (self.id, self.name, self.tribe.name) def to_dict(self, full_tribe=False) -> dict: return {"id": self.id, "name": self.name, "tribe_name": self.tribe.name}