mirror of https://github.com/eyhc1/rendercv.git
update data_models.py
This commit is contained in:
parent
246213aaf2
commit
875c63d5e5
|
@ -197,17 +197,20 @@ class EntryBase(RenderCVBaseModel):
|
||||||
if model.end_date is not None:
|
if model.end_date is not None:
|
||||||
end_date_is_provided = True
|
end_date_is_provided = True
|
||||||
|
|
||||||
if date_is_provided and start_date_is_provided and end_date_is_provided:
|
if date_is_provided:
|
||||||
model.start_date = None
|
try:
|
||||||
model.end_date = None
|
date_object = get_date_object(model.date) # type: ignore
|
||||||
|
except ValueError:
|
||||||
elif date_is_provided and start_date_is_provided and not end_date_is_provided:
|
# Then it is a custom date string (e.g., "My Custom Date")
|
||||||
model.start_date = None
|
pass
|
||||||
model.end_date = None
|
else:
|
||||||
|
today_object = Date.today()
|
||||||
elif date_is_provided and end_date_is_provided and not start_date_is_provided:
|
if date_object > today_object:
|
||||||
model.start_date = None
|
raise ValueError(
|
||||||
model.end_date = None
|
'"date" cannot be in the future.',
|
||||||
|
"date", # this is the location of the error
|
||||||
|
model.date, # this is value of the error
|
||||||
|
)
|
||||||
|
|
||||||
elif start_date_is_provided and not end_date_is_provided:
|
elif start_date_is_provided and not end_date_is_provided:
|
||||||
model.end_date = "present"
|
model.end_date = "present"
|
||||||
|
@ -243,12 +246,6 @@ class EntryBase(RenderCVBaseModel):
|
||||||
"end_date", # this is the location of the error
|
"end_date", # this is the location of the error
|
||||||
model.end_date, # this is value of the error
|
model.end_date, # this is value of the error
|
||||||
)
|
)
|
||||||
elif start_date > Date.today():
|
|
||||||
raise ValueError(
|
|
||||||
'"start_date" cannot be in the future.',
|
|
||||||
"start_date", # this is the location of the error
|
|
||||||
model.start_date, # this is value of the error
|
|
||||||
)
|
|
||||||
|
|
||||||
return model
|
return model
|
||||||
|
|
||||||
|
@ -520,8 +517,6 @@ class PublicationEntry(RenderCVBaseModel):
|
||||||
elif isinstance(self.date, str):
|
elif isinstance(self.date, str):
|
||||||
date_object = get_date_object(self.date)
|
date_object = get_date_object(self.date)
|
||||||
date_string = format_date(date_object)
|
date_string = format_date(date_object)
|
||||||
else:
|
|
||||||
date_string = ""
|
|
||||||
|
|
||||||
return date_string
|
return date_string
|
||||||
|
|
||||||
|
@ -645,10 +640,7 @@ def get_entry_and_section_type(
|
||||||
section type.
|
section type.
|
||||||
"""
|
"""
|
||||||
if isinstance(entry, dict):
|
if isinstance(entry, dict):
|
||||||
if isinstance(entry, str):
|
if "details" in entry:
|
||||||
entry_type = "TextEntry"
|
|
||||||
section_type = SectionWithTextEntries
|
|
||||||
elif "details" in entry:
|
|
||||||
entry_type = "OneLineEntry"
|
entry_type = "OneLineEntry"
|
||||||
section_type = SectionWithOneLineEntries
|
section_type = SectionWithOneLineEntries
|
||||||
elif "company" in entry:
|
elif "company" in entry:
|
||||||
|
@ -887,6 +879,7 @@ class RenderCVDataModel(RenderCVBaseModel):
|
||||||
description="The data of the CV.",
|
description="The data of the CV.",
|
||||||
)
|
)
|
||||||
design: Design = pydantic.Field(
|
design: Design = pydantic.Field(
|
||||||
|
default=ClassicThemeOptions(theme="classic"),
|
||||||
title="Design",
|
title="Design",
|
||||||
description="The design information of the CV.",
|
description="The design information of the CV.",
|
||||||
discriminator="theme",
|
discriminator="theme",
|
||||||
|
@ -1313,9 +1306,9 @@ def generate_json_schema() -> dict:
|
||||||
# is the string with the YYYY-MM-DD format.
|
# is the string with the YYYY-MM-DD format.
|
||||||
if (
|
if (
|
||||||
"date" in value["properties"]
|
"date" in value["properties"]
|
||||||
and "anyOf" in value["properties"]["date"]
|
and "oneOf" in value["properties"]["date"]
|
||||||
):
|
):
|
||||||
del value["properties"]["date"]["anyOf"][0]
|
del value["properties"]["date"]["oneOf"][0]
|
||||||
|
|
||||||
return json_schema
|
return json_schema
|
||||||
|
|
||||||
|
|
55
schema.json
55
schema.json
|
@ -543,10 +543,6 @@
|
||||||
],
|
],
|
||||||
"title": "Date",
|
"title": "Date",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-\\d{2}(-\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
@ -703,10 +699,6 @@
|
||||||
],
|
],
|
||||||
"title": "Date",
|
"title": "Date",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-\\d{2}(-\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
@ -844,10 +836,6 @@
|
||||||
],
|
],
|
||||||
"title": "Date",
|
"title": "Date",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-\\d{2}(-\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
|
@ -977,9 +965,6 @@
|
||||||
],
|
],
|
||||||
"title": "Publication Date",
|
"title": "Publication Date",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"pattern": "\\d{4}-\\d{2}(-\\d{2})?",
|
"pattern": "\\d{4}-\\d{2}(-\\d{2})?",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -1254,6 +1239,43 @@
|
||||||
"title": "Curriculum Vitae"
|
"title": "Curriculum Vitae"
|
||||||
},
|
},
|
||||||
"design": {
|
"design": {
|
||||||
|
"default": {
|
||||||
|
"theme": "classic",
|
||||||
|
"font": "SourceSans3",
|
||||||
|
"font_size": "10pt",
|
||||||
|
"page_size": "a4paper",
|
||||||
|
"primary_color": "#004f90",
|
||||||
|
"date_and_location_width": "4.1 cm",
|
||||||
|
"text_alignment": "left-aligned",
|
||||||
|
"show_timespan_in": [],
|
||||||
|
"show_last_updated_date": true,
|
||||||
|
"header_font_size": "30 pt",
|
||||||
|
"margins": {
|
||||||
|
"entry_area": {
|
||||||
|
"left_and_right": "0.2 cm",
|
||||||
|
"vertical_between": "0.12 cm"
|
||||||
|
},
|
||||||
|
"header": {
|
||||||
|
"bottom": "0.2 cm",
|
||||||
|
"vertical_between_name_and_connections": "0.2 cm"
|
||||||
|
},
|
||||||
|
"highlights_area": {
|
||||||
|
"left": "0.4 cm",
|
||||||
|
"top": "0.10 cm",
|
||||||
|
"vertical_between_bullet_points": "0.10 cm"
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"bottom": "2 cm",
|
||||||
|
"left": "1.24 cm",
|
||||||
|
"right": "1.24 cm",
|
||||||
|
"top": "2 cm"
|
||||||
|
},
|
||||||
|
"section_title": {
|
||||||
|
"bottom": "0.2 cm",
|
||||||
|
"top": "0.2 cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"description": "The design information of the CV.",
|
"description": "The design information of the CV.",
|
||||||
"discriminator": {
|
"discriminator": {
|
||||||
"mapping": {
|
"mapping": {
|
||||||
|
@ -1270,8 +1292,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
"cv",
|
"cv"
|
||||||
"design"
|
|
||||||
],
|
],
|
||||||
"title": "RenderCV",
|
"title": "RenderCV",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|
Loading…
Reference in New Issue