Fixed HP import crash if teacher name not found

This commit is contained in:
Claude Paroz 2018-05-25 11:27:48 +02:00
parent d9b714ceca
commit d180c6ec7b
3 changed files with 12 additions and 2 deletions

View file

@ -422,8 +422,16 @@ class HPImportView(ImportViewBase):
if (line['LIBELLE_MAT'] == '' or line['NOMPERSO_DIP'] == '' or line['TOTAL'] == ''):
continue
try:
teacher = profs[line['NOMPERSO_ENS']]
except KeyError:
errors.append(
"Impossible de trouver «%s» dans la liste des enseignant-e-s" % line['NOMPERSO_ENS']
)
continue
obj, created = Course.objects.get_or_create(
teacher=profs[line['NOMPERSO_ENS']],
teacher=teacher,
subject=line['LIBELLE_MAT'],
public=line['NOMPERSO_DIP'],
)