imporve section_order validation

This commit is contained in:
Sina Atalay 2023-10-18 20:05:40 +02:00
parent 0ec1ef1ee2
commit 8a2045c7a1
1 changed files with 21 additions and 0 deletions

View File

@ -55,6 +55,9 @@ dictionary = [
"siemens", "siemens",
"dynamometer", "dynamometer",
"dc", "dc",
"grammarly",
"css",
"html"
] ]
@ -1213,6 +1216,24 @@ class CurriculumVitae(BaseModel):
) )
sections.append(section) sections.append(section)
# Check if any of the pre-defined sections are missing from the section order:
for section_name in pre_defined_sections:
if pre_defined_sections[section_name] is not None:
if section_name not in self.section_order:
logger.warning(
f'The section "{section_name}" is not found in the section'
" order! It will not be rendered."
)
# Check if any of the custom sections are missing from the section order:
if self.custom_sections is not None:
for custom_section in self.custom_sections:
if custom_section.title not in self.section_order:
logger.warning(
f'The custom section "{custom_section.title}" is not found in'
" the section order! It will not be rendered."
)
return sections return sections