diff --git a/stages/test_files/CLOEE2_Export_FE_2018.xlsx b/stages/test_files/CLOEE2_Export_FE_2018.xlsx new file mode 100644 index 0000000..3de7548 Binary files /dev/null and b/stages/test_files/CLOEE2_Export_FE_2018.xlsx differ diff --git a/stages/test_files/EXPORT_GAN.xlsx b/stages/test_files/EXPORT_GAN.xlsx deleted file mode 100644 index 8c90ca5..0000000 Binary files a/stages/test_files/EXPORT_GAN.xlsx and /dev/null differ diff --git a/stages/tests.py b/stages/tests.py index 6f7cf22..ef342da 100644 --- a/stages/tests.py +++ b/stages/tests.py @@ -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( diff --git a/stages/views/imports.py b/stages/views/imports.py index 7b63d95..66fa4a1 100644 --- a/stages/views/imports.py +++ b/stages/views/imports.py @@ -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):