Files
resume/cv/services/dowload/base.py
Pavel Sobolev c4bb087aaf First commite
2025-11-12 23:49:00 +03:00

31 lines
978 B
Python

from __future__ import annotations
from io import BytesIO
from typing import Any, Dict, Protocol
class ProfileSerializer:
"""Сериализатор данных профиля для рендереров."""
def serialize(self, profile) -> Dict[str, Any]:
return {
"full_name": profile.full_name,
"role": getattr(profile, "role", ""),
"summary": getattr(profile, "summary", ""),
"location": getattr(profile, "location", ""),
"languages": getattr(profile, "languages", []) or [],
"contacts": {
"email": getattr(profile, "email", ""),
"phone": getattr(profile, "phone", ""),
"telegram": getattr(profile, "telegram", ""),
},
"experience": list(profile.experience.all()),
"skills_map": list(profile.skills_map.all()),
}
class Renderer(Protocol):
def render(self, profile) -> BytesIO: ...