Commit 5444dee0 authored by Vilem Ded's avatar Vilem Ded
Browse files

throw error when contact is missing

- error is written to log file if a key contactact is missing (DPO,main,
legal representative)
parent db811b1d
......@@ -268,41 +268,63 @@ class DishXlsExporter:
elif is_submission(sheet):
dataset_dict["name"] = sheet[2, 1].strip()
dataset_dict["project"] = sheet[5, 1].strip()
dataset_dict["contacts"].extend([{"first_name": get_names_from_string(sheet[9, 1])[0],
dataset_dict["contacts"].extend(self.get_submission_contacts(sheet))
else:
pass
idx += 1
logging.info('Processing end for ----> {}'.format(full_file_path))
return dataset_dict
else:
raise ValueError("{} not a valid DISH Excel file".format(full_file_path))
def get_submission_contacts(self, sheet):
contacts = []
affiliations = [self.process_institution(sheet[7,1])]
if sheet[9, 1]:
contacts.append({
"first_name": get_names_from_string(sheet[9, 1])[0],
"last_name":get_names_from_string(sheet[9, 1])[1],
"role": sheet[11,1],
"email":sheet[10,1].strip(),
"affiliations": [self.process_institution(sheet[7,1])]
},
{"first_name": get_names_from_string(sheet[12, 1])[0],
"last_name":get_names_from_string(sheet[12, 1])[1],
"affiliations": affiliations
})
else:
logging.error("Submission contact missing - Main contact!")
if sheet[12,1]:
contacts.append({
"first_name": get_names_from_string(sheet[12, 1])[0],
"last_name": get_names_from_string(sheet[12, 1])[1],
"role": "Legal_Representative",
"email":sheet[13,1].strip(),
"affiliations": [self.process_institution(sheet[7,1])]
},
{"first_name": get_names_from_string(sheet[14, 1])[0],
"last_name":get_names_from_string(sheet[14, 1])[1],
"email": sheet[13,1].strip(),
"affiliations": affiliations
})
else:
logging.error("Submission contact missing - Legal Representative!")
if sheet[14, 1]:
contacts.append({
"first_name": get_names_from_string(sheet[14, 1])[0],
"last_name": get_names_from_string(sheet[14, 1])[1],
"role": "Data_Protection_Officer",
"email":sheet[15,1].strip(),
"affiliations": [self.process_institution(sheet[7,1])]
}])
"email": sheet[15,1].strip(),
"affiliations": affiliations
})
else:
logging.error("Submission contact missing - DPO!")
if sheet[16, 1] and sheet[18, 1]:
dataset_dict["contacts"].append({"first_name": get_names_from_string(sheet[16, 1])[0],
contacts.append({
"first_name": get_names_from_string(sheet[16, 1])[0],
"last_name": get_names_from_string(sheet[16, 1])[1],
"role": sheet[18,1],
"email": sheet[17,1].strip(),
"affiliations": [self.process_institution(sheet[7,1])]
"affiliations": affiliations
})
else:
pass
idx += 1
logging.info('Processing end for ----> {}'.format(full_file_path))
return dataset_dict
else:
raise ValueError("{} not a valid DISH Excel file".format(full_file_path))
return contacts
def get_hash_for_path(self, path):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment