improve data model

This commit is contained in:
Sina Atalay 2023-09-04 19:31:11 +02:00
parent e17656b431
commit 7c5440a300
3 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,7 @@
from pydantic import BaseModel
from .content import CurriculumVitae
from .design import Design
class RenderCVDataModel(BaseModel):
design: Design
cv: CurriculumVitae

View File

@ -0,0 +1,32 @@
from pydantic import BaseModel, Field, HttpUrl, model_validator
from pydantic_extra_types.color import Color
from typing import Literal
from datetime import date as Date
class ClassicTheme(BaseModel):
# 1) Mandotory user inputs:
# 2) Optional user inputs:
primary_color: Color = Field(default="blue")
page_top_margin: str = Field(default="1.35cm")
page_bottom_margin: str = Field(default="1.35cm")
page_left_margin: str = Field(default="1.35cm")
page_right_margin: str = Field(default="1.35cm")
section_title_top_margin: str = Field(default="0.13cm")
section_title_bottom_margin: str = Field(default="0.13cm")
vertical_margin_between_sections: str = Field(default="0.13cm")
vertical_margin_between_bullet_points: str = Field(default="0.07cm")
bullet_point_left_margin: str = Field(default="0.7cm")
vertical_margin_between_entries: str = Field(default="0.12cm")
vertical_margin_between_entries_and_highlights: str = Field(default="0.12cm")
date_and_location_width: str = Field(default="3.7cm")
class Design(BaseModel):
theme: Literal['classic'] = 'classic'
options: ClassicTheme

View File

@ -1,6 +1,6 @@
from jinja2 import Environment, FileSystemLoader
from data.content import CurriculumVitae
from data.data_model import RenderCVDataModel
# from . import tinytex # https://github.com/praw-dev/praw/blob/master/praw/reddit.py
# from . import templates, sonra mesela: classic.render() tarzi seyler olabilir
@ -30,9 +30,9 @@ if __name__ == "__main__":
with open(input_file_path) as file:
raw_json = json.load(file)
cv = CurriculumVitae(**raw_json)
data = RenderCVDataModel(**raw_json)
output_latex_file = template.render(cv=cv)
output_latex_file = template.render(design=data.design.options, cv=data.cv)
# Create an output file and write the rendered LaTeX code to it:
output_file_path = os.path.join(workspace, "tests", "outputs", "test.tex")