mirror of https://github.com/eyhc1/rendercv.git
update data model
This commit is contained in:
parent
100f93a925
commit
e81f1b800a
|
@ -1,17 +1,9 @@
|
||||||
from pydantic import BaseModel, HttpUrl, model_validator
|
from pydantic import BaseModel, HttpUrl, model_validator
|
||||||
from pydantic_extra_types.phone_numbers import PhoneNumber
|
from pydantic_extra_types.phone_numbers import PhoneNumber
|
||||||
from typing import Literal
|
from typing import Literal, Union
|
||||||
from datetime import date as Date
|
from datetime import date as Date
|
||||||
|
|
||||||
|
|
||||||
class Location(BaseModel):
|
|
||||||
# 1) Mandotory user inputs:
|
|
||||||
city: str
|
|
||||||
country: str
|
|
||||||
# 2) Optional user inputs:
|
|
||||||
state: str = None
|
|
||||||
|
|
||||||
|
|
||||||
class Skill(BaseModel):
|
class Skill(BaseModel):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
name: str
|
name: str
|
||||||
|
@ -31,10 +23,11 @@ class TestScore(BaseModel):
|
||||||
class Project(BaseModel):
|
class Project(BaseModel):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
name: str
|
name: str
|
||||||
location: Location
|
location: str
|
||||||
# 2) Optional user inputs:
|
# 2) Optional user inputs:
|
||||||
start_date: Date = None
|
start_date: Date = None
|
||||||
end_date: Date = None
|
end_date: Date | Literal["present"] = None
|
||||||
|
date: str = None
|
||||||
url: HttpUrl = None
|
url: HttpUrl = None
|
||||||
highlights: list[str] = None
|
highlights: list[str] = None
|
||||||
|
|
||||||
|
@ -43,10 +36,11 @@ class Experience(BaseModel):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
company: str
|
company: str
|
||||||
position: str
|
position: str
|
||||||
start_date: Date
|
location: str
|
||||||
location: Location
|
|
||||||
# 2) Optional user inputs:
|
# 2) Optional user inputs:
|
||||||
end_date: Date = None
|
start_date: Date = None
|
||||||
|
end_date: Date | Literal["present"] = None
|
||||||
|
date: str = None
|
||||||
highlights: list[str] = None
|
highlights: list[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,10 +48,11 @@ class Education(BaseModel):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
institution: str
|
institution: str
|
||||||
area: str
|
area: str
|
||||||
location: Location
|
location: str
|
||||||
start_date: Date
|
|
||||||
# 2) Optional user inputs:
|
# 2) Optional user inputs:
|
||||||
end_date: Date = None
|
start_date: Date = None
|
||||||
|
end_date: Date | Literal["present"] = None
|
||||||
|
date: str = None
|
||||||
study_type: str = None
|
study_type: str = None
|
||||||
gpa: str = None
|
gpa: str = None
|
||||||
transcript_url: HttpUrl = None
|
transcript_url: HttpUrl = None
|
||||||
|
@ -69,11 +64,13 @@ class SocialNetwork(BaseModel):
|
||||||
network: Literal["LinkedIn", "GitHub", "Instagram"]
|
network: Literal["LinkedIn", "GitHub", "Instagram"]
|
||||||
username: str
|
username: str
|
||||||
|
|
||||||
|
|
||||||
class Connection(BaseModel):
|
class Connection(BaseModel):
|
||||||
# 3) Derived fields (not user inputs):
|
# 3) Derived fields (not user inputs):
|
||||||
name: Literal["LinkedIn", "GitHub", "Instagram", "phone", "email", "website"]
|
name: Literal["LinkedIn", "GitHub", "Instagram", "phone", "email", "website"]
|
||||||
value: str
|
value: str
|
||||||
|
|
||||||
|
|
||||||
class CurriculumVitae(BaseModel):
|
class CurriculumVitae(BaseModel):
|
||||||
# 1) Mandotory user inputs:
|
# 1) Mandotory user inputs:
|
||||||
name: str
|
name: str
|
||||||
|
@ -81,7 +78,7 @@ class CurriculumVitae(BaseModel):
|
||||||
email: str = None
|
email: str = None
|
||||||
phone: PhoneNumber = None
|
phone: PhoneNumber = None
|
||||||
website: HttpUrl = None
|
website: HttpUrl = None
|
||||||
location: Location = None
|
location: str = None
|
||||||
social_networks: list[SocialNetwork] = None
|
social_networks: list[SocialNetwork] = None
|
||||||
education: list[Education] = None
|
education: list[Education] = None
|
||||||
work_experience: list[Experience] = None
|
work_experience: list[Experience] = None
|
||||||
|
@ -105,10 +102,10 @@ class CurriculumVitae(BaseModel):
|
||||||
connections.append(Connection(name="website", value=model.website))
|
connections.append(Connection(name="website", value=model.website))
|
||||||
if model.social_networks is not None:
|
if model.social_networks is not None:
|
||||||
for social_network in model.social_networks:
|
for social_network in model.social_networks:
|
||||||
connections.append(Connection(
|
connections.append(
|
||||||
name=social_network.network,
|
Connection(
|
||||||
value=social_network.username
|
name=social_network.network, value=social_network.username
|
||||||
))
|
)
|
||||||
|
)
|
||||||
model.connections = connections
|
model.connections = connections
|
||||||
return model
|
return model
|
||||||
|
|
Loading…
Reference in New Issue