Skip to content
Snippets Groups Projects

Cristin64

Merged Petr.Kalashnikov requested to merge cristin64 into master
2 unresolved threads
+ 20
4
@@ -128,6 +128,26 @@ def add_persons(root: ET.Element,
"""Add persons to the Element"""
personer = ET.SubElement(root, 'personer')
for person_data in persons:
if '_stillinger' in person_data and len(person_data['_stillinger']) > 0:
for stilling in person_data['_stillinger']:
stil_model = Stilling(**stilling)
if not stilling_validate_fields(stil_model):
logger.warning(
"Employee %s has insufficient employment info in db."
" Skipping employment info.",
person_data["id"])
continue
org_enhet_nr = int(stil_model.organisasjon_id)
if org_enhet_nr not in organizations:
logger.warning("No orgenhet found for stilling %r",
stilling)
continue
org = organizations[org_enhet_nr]
avd, undavd, gruppe = get_stedkode(context, org.id)
stedskode = str(avd) + str(undavd) + str(gruppe)
if not stedskode in stedskoder:
continue
# Validate and adjust values if possible, otherwise skip person
values = {
"etternavn": person_data['etternavn'],
@@ -182,10 +202,6 @@ def add_persons(root: ET.Element,
avd, undavd, gruppe = get_stedkode(context, org.id)
if not avd or not undavd or not gruppe:
continue
stedskode = str(avd) + str(undavd) + str(gruppe)
if not stedskode in stedskoder:
continue
# Don't create the ansettelser element until we know we can add at least
# one element to it
if not ansettelser_made:
Loading