mirror of https://github.com/eyhc1/rendercv.git
data_models: make DOI optional for PublicationEntry (#33)
This commit is contained in:
parent
5169612ece
commit
0354b77fab
|
@ -483,7 +483,8 @@ class PublicationEntry(RenderCVBaseModel):
|
|||
title="Authors",
|
||||
description="The authors of the publication in order as a list of strings.",
|
||||
)
|
||||
doi: str = pydantic.Field(
|
||||
doi: Optional[str] = pydantic.Field(
|
||||
default=None,
|
||||
title="DOI",
|
||||
description="The DOI of the publication.",
|
||||
examples=["10.48550/arXiv.2310.03138"],
|
||||
|
@ -513,10 +514,11 @@ class PublicationEntry(RenderCVBaseModel):
|
|||
|
||||
@pydantic.field_validator("doi")
|
||||
@classmethod
|
||||
def check_doi(cls, doi: str) -> str:
|
||||
def check_doi(cls, doi: Optional[str]) -> Optional[str]:
|
||||
"""Check if the DOI exists in the DOI System."""
|
||||
# see https://stackoverflow.com/a/60671292/18840665 for the explanation of the
|
||||
# next line:
|
||||
if doi is not None:
|
||||
# see https://stackoverflow.com/a/60671292/18840665 for the explanation of
|
||||
# the next line:
|
||||
ssl._create_default_https_context = ssl._create_unverified_context # type: ignore
|
||||
|
||||
doi_url = f"http://doi.org/{doi}"
|
||||
|
@ -532,6 +534,11 @@ class PublicationEntry(RenderCVBaseModel):
|
|||
@functools.cached_property
|
||||
def doi_url(self) -> str:
|
||||
"""Return the URL of the DOI."""
|
||||
# self.doi == "" is added because None values are replaced with "" in
|
||||
# renderer.TemplatedFile class (to make templating easier)
|
||||
if self.doi is None or self.doi == "":
|
||||
return ""
|
||||
else:
|
||||
return f"https://doi.org/{self.doi}"
|
||||
|
||||
@functools.cached_property
|
||||
|
|
24
schema.json
24
schema.json
|
@ -4,6 +4,10 @@
|
|||
"additionalProperties": false,
|
||||
"description": "This class is the data model of the theme options for the classic theme.",
|
||||
"properties": {
|
||||
"theme": {
|
||||
"const": "classic",
|
||||
"title": "Theme"
|
||||
},
|
||||
"font_size": {
|
||||
"default": "10pt",
|
||||
"description": "The font size of the CV. The default value is 10pt.",
|
||||
|
@ -109,10 +113,6 @@
|
|||
"description": "Page, section title, entry field, and highlights field margins.",
|
||||
"title": "Margins"
|
||||
},
|
||||
"theme": {
|
||||
"const": "classic",
|
||||
"title": "Theme"
|
||||
},
|
||||
"show_timespan_in": {
|
||||
"default": [],
|
||||
"description": "The time span will be shown in the date and location column in these sections. The input should be a list of section titles as strings (case-sensitive). The default value is an empty list, which means the time span will not be shown in any section.",
|
||||
|
@ -962,12 +962,17 @@
|
|||
"type": "array"
|
||||
},
|
||||
"doi": {
|
||||
"default": null,
|
||||
"description": "The DOI of the publication.",
|
||||
"examples": [
|
||||
"10.48550/arXiv.2310.03138"
|
||||
],
|
||||
"title": "DOI",
|
||||
"allOf": [
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"date": {
|
||||
"default": "2020-01-01",
|
||||
|
@ -998,7 +1003,6 @@
|
|||
"required": [
|
||||
"title",
|
||||
"authors",
|
||||
"doi",
|
||||
"date"
|
||||
],
|
||||
"title": "PublicationEntry",
|
||||
|
@ -1008,6 +1012,10 @@
|
|||
"additionalProperties": false,
|
||||
"description": "This class is the data model of the theme options for the sb2nov theme.",
|
||||
"properties": {
|
||||
"theme": {
|
||||
"const": "sb2nov",
|
||||
"title": "Theme"
|
||||
},
|
||||
"font_size": {
|
||||
"default": "10pt",
|
||||
"description": "The font size of the CV. The default value is 10pt.",
|
||||
|
@ -1112,10 +1120,6 @@
|
|||
},
|
||||
"description": "Page, section title, entry field, and highlights field margins.",
|
||||
"title": "Margins"
|
||||
},
|
||||
"theme": {
|
||||
"const": "sb2nov",
|
||||
"title": "Theme"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
@ -1191,6 +1195,7 @@
|
|||
},
|
||||
"design": {
|
||||
"default": {
|
||||
"theme": "classic",
|
||||
"font_size": "10pt",
|
||||
"page_size": "letterpaper",
|
||||
"color": "#004f90",
|
||||
|
@ -1226,7 +1231,6 @@
|
|||
"top": "0.3 cm"
|
||||
}
|
||||
},
|
||||
"theme": "classic",
|
||||
"show_timespan_in": []
|
||||
},
|
||||
"description": "The design information of the CV. The default is the classic theme.",
|
||||
|
|
Loading…
Reference in New Issue