Commit fc15087b authored by Vilem Ded's avatar Vilem Ded
Browse files

Merge branch 'curate-missing-contacts' into 'master'

throw error when contact is missing

See merge request pinar.alper/metadata-tools!13
parents db811b1d 5444dee0
...@@ -268,32 +268,7 @@ class DishXlsExporter: ...@@ -268,32 +268,7 @@ class DishXlsExporter:
elif is_submission(sheet): elif is_submission(sheet):
dataset_dict["name"] = sheet[2, 1].strip() dataset_dict["name"] = sheet[2, 1].strip()
dataset_dict["project"] = sheet[5, 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))
"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],
"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],
"role": "Data_Protection_Officer",
"email":sheet[15,1].strip(),
"affiliations": [self.process_institution(sheet[7,1])]
}])
if sheet[16, 1] and sheet[18, 1]:
dataset_dict["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])]
})
else: else:
pass pass
...@@ -304,6 +279,53 @@ class DishXlsExporter: ...@@ -304,6 +279,53 @@ class DishXlsExporter:
else: else:
raise ValueError("{} not a valid DISH Excel file".format(full_file_path)) 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": 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": 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": affiliations
})
else:
logging.error("Submission contact missing - DPO!")
if sheet[16, 1] and sheet[18, 1]:
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": affiliations
})
return contacts
def get_hash_for_path(self, path): def get_hash_for_path(self, path):
self.h.update(fsencode(path)) self.h.update(fsencode(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