Exemplo n.º 1
0
def create_admission(row, etat_civil):
    """Read an excel row and save the corresponding Admission object in database"""
    errors = []
    ad = Admission()
    try :
        ad.filiere_org = FiliereAdmission.objects.get(nom=row['origine_avant_BS'])
    except FiliereAdmission.DoesNotExist:
        ad.filiere_org = FiliereAdmission(nom=row['origine_avant_BS'])
    try:
        ad.domaine_org = DomaineAdmission.objects.get(nom=row['filiere_avant_BS'])
    except DomaineAdmission.DoesNotExist:
        ad.domaine_org = DomaineAdmission(nom=row['filiere_avant_BS'])
    ad.annee_admission = row['annee_admission']
    ad.rang_pre_BS = row['classement_avant_BS']
    ad.taille_promo_pre_BS = row['taille_de_promo_avant_BS']
    try:
        ad.full_clean()
    except ValidationError, e:
        m = dict(e.message_dict)
        errors.append([str("%s %s"%(etat_civil.prenom, etat_civil.nom_insa)), [list(k) for k in zip(m.keys(),m.values())]]) 
Exemplo n.º 2
0
    def test_create_admission(self):
        fa = FiliereAdmission.objects.get(nom='Ecole Jedi')
        da = DomaineAdmission.objects.get(nom='Parachutage')

        ad = Admission()
        ad.filiere_org = fa
        ad.domaine_org = da
        ad.annee_admission = 3
        ad.rang_pre_BS = 5
        ad.taille_promo_pre_BS = 100
        ad.save()

        # ad exists in DB ?
        self.assertNotEqual(ad.id, 0)

        # can we retrieve ad in DB ?
        ad_id = ad.id
        ad = None
        ad = Admission.objects.get(id=ad_id)
        self.assertEqual(ad.filiere_org, fa)
        self.assertEqual(ad.domaine_org, da)
        self.assertEqual(ad.annee_admission, 3)
        self.assertEqual(ad.rang_pre_BS, 5)
        self.assertEqual(ad.taille_promo_pre_BS, 100)
Exemplo n.º 3
0
    def test_create_admission(self):
        fa = FiliereAdmission.objects.get(nom='Ecole Jedi')
        da = DomaineAdmission.objects.get(nom='Parachutage')

        ad = Admission()
        ad.filiere_org = fa
        ad.domaine_org = da
        ad.annee_admission = 3
        ad.rang_pre_BS = 5
        ad.taille_promo_pre_BS = 100
        ad.save()

        # ad exists in DB ?
        self.assertNotEqual(ad.id, 0)
        
        # can we retrieve ad in DB ?
        ad_id = ad.id     
        ad = None
        ad = Admission.objects.get(id = ad_id)
        self.assertEqual(ad.filiere_org, fa)
        self.assertEqual(ad.domaine_org, da)
        self.assertEqual(ad.annee_admission, 3)
        self.assertEqual(ad.rang_pre_BS, 5)
        self.assertEqual(ad.taille_promo_pre_BS, 100)
Exemplo n.º 4
0
def create_admission(row, etat_civil):
    """Read an excel row and save the corresponding Admission object in database"""
    errors = []
    ad = Admission()
    try:
        ad.filiere_org = FiliereAdmission.objects.get(
            nom=row['origine_avant_BS'])
    except FiliereAdmission.DoesNotExist:
        ad.filiere_org = FiliereAdmission(nom=row['origine_avant_BS'])
    try:
        ad.domaine_org = DomaineAdmission.objects.get(
            nom=row['filiere_avant_BS'])
    except DomaineAdmission.DoesNotExist:
        ad.domaine_org = DomaineAdmission(nom=row['filiere_avant_BS'])
    ad.annee_admission = row['annee_admission']
    ad.rang_pre_BS = row['classement_avant_BS']
    ad.taille_promo_pre_BS = row['taille_de_promo_avant_BS']
    try:
        ad.full_clean()
    except ValidationError, e:
        m = dict(e.message_dict)
        errors.append([
            str("%s %s" % (etat_civil.prenom, etat_civil.nom_insa)),
            [list(k) for k in zip(m.keys(), m.values())]
        ])