Student import file headers have changed in 2018

This commit is contained in:
Claude Paroz 2018-07-13 12:43:27 +02:00
parent d3fd0e920c
commit cf1b97a56f
4 changed files with 37 additions and 30 deletions

Binary file not shown.

Binary file not shown.

View file

@ -441,34 +441,40 @@ class ImportTests(TestCase):
"""
Import of the main students file.
"""
path = os.path.join(os.path.dirname(__file__), 'test_files', 'EXPORT_GAN.xlsx')
path = os.path.join(os.path.dirname(__file__), 'test_files', 'CLOEE2_Export_FE_2018.xlsx')
self.client.login(username='me', password='mepassword')
with open(path, 'rb') as fh:
response = self.client.post(reverse('import-students'), {'upload': fh}, follow=True)
msg = "\n".join(str(m) for m in response.context['messages'])
self.assertIn("La classe '1ASEFEa' n'existe pas encore", msg)
self.assertIn("La classe '1ASSCFEa' n'existe pas encore", msg)
lev1 = Level.objects.create(name='1')
lev2 = Level.objects.create(name='2')
Klass.objects.create(
name='1ASEFEa',
section=Section.objects.create(name='ASE'),
name='1ASSCFEa',
section=Section.objects.create(name='ASSC'),
level=lev1,
)
Klass.objects.create(
name='1EDS',
name='2EDEpe',
section=Section.objects.create(name='EDE'),
level=lev2,
)
Klass.objects.create(
name='1EDS18-20',
section=Section.objects.create(name='EDS'),
level=lev1,
)
Option.objects.create(name='Accompagnement des enfants')
with open(path, 'rb') as fh: # , override_settings(DEBUG=True):
with open(path, 'rb') as fh:
response = self.client.post(reverse('import-students'), {'upload': fh}, follow=True)
msg = "\n".join(str(m) for m in response.context['messages'])
self.assertIn("Objets créés : 3", msg)
student1 = Student.objects.get(last_name='Fellmann')
self.assertEqual(student1.corporation.name, "Crèche Les Mousaillons")
self.assertEqual(student1.option_ase.name, "Accompagnement des enfants")
student = Student.objects.get(ext_id=22222)
self.assertEqual(student.corporation.name, 'Accueil Haut les mains')
self.assertFalse(student.dispense_eps)
# Instructor not set through this import
self.assertIsNone(student1.instructor)
self.assertIsNone(student.instructor)
def test_import_hp(self):
teacher = Teacher.objects.create(

View file

@ -68,27 +68,28 @@ class StudentImportView(ImportViewBase):
form_class = StudentImportForm
# Mapping between column names of a tabular file and Student field names
student_mapping = {
'NOCLOEE': 'ext_id',
'NOM': 'last_name',
'PRENOM': 'first_name',
'RUE': 'street',
'LOCALITE': 'city', # pcode is separated from city in prepare_import
'TEL_PRIVE': 'tel',
'TEL_MOBILE': 'mobile',
'EMAIL_RPN': 'email',
'DATENAI': 'birth_date',
'NAVS13': 'avs',
'SEXE': 'gender',
'CLASSE_ACTUELLE': 'klass',
'LIB_BRANCHE_OPTION': 'option_ase',
'ELE_NUMERO': 'ext_id',
'ELE_NOM': 'last_name',
'ELE_PRENOM': 'first_name',
'ELE_RUE': 'street',
'ELE_NPA_LOCALITE': 'city', # pcode is separated from city in prepare_import
'ELE_TEL_PRIVE': 'tel',
'ELE_TEL_MOBILE': 'mobile',
'ELE_EMAIL_RPN': 'email',
'ELE_DATE_NAISSANCE': 'birth_date',
'ELE_AVS': 'avs',
'ELE_SEXE': 'gender',
'INS_CLASSE': 'klass',
'PROF_DOMAINE_SPEC': 'option_ase',
}
corporation_mapping = {
'NO_EMPLOYEUR' : 'ext_id',
'EMPLOYEUR' : 'name',
'RUE_EMPLOYEUR': 'street',
'LOCALITE_EMPLOYEUR': 'city',
'TEL_EMPLOYEUR': 'tel',
'CANTON_EMPLOYEUR' : 'district',
'ENT_NUMERO' : 'ext_id',
'ENT_NOM' : 'name',
'ENT_RUE': 'street',
'ENT_NPA': 'pcode',
'ENT_LOCALITE': 'city',
'ENT_TEL': 'tel',
'ENT_CODE_CANTON' : 'district',
}
def get_form_kwargs(self):