示例#1
0
    def get_save_teachers(self):
        """
        Read students data from xml
        """
        self.log(logging.INFO, "Getting/saving teachers")
        self.teachers = {}
        fmap = {
            'lastname': 'NOM_USAGE',
            'firstname': 'PRENOM',
            'birthname': 'NOM_PATRONYMIQUE',
            'birthday': 'DATE_NAISSANCE',
        }
        for node in self.xml['STS_EDT'].\
                findall("./DONNEES/INDIVIDUS/INDIVIDU"):
            data = self._getfmap(node, fmap)
            # SEE: Uniquid stable ?
            data['uniquid'] = node.get("ID")
            data['birthday'] = datetime.datetime.strptime(
                data['birthday'], "%Y-%m-%d")
            data['ttype'] = node.get("TYPE")
            teacher = Teacher(**data)
            self.teachers[data['uniquid']] = \
                Teacher.add_or_update(teacher, self.log)
        self.log(logging.INFO, "Getting / saving teachers : DONE")



register_filter("STSProfEmp", STSProfEmpFilter)

示例#2
0
                                havemef = True
                                break

                        if havemef and struct.code in self.students_structures:
                            gpe = self.students_structures[struct.code].values()
                            self.log(logging.DEBUG,
                                     "Added %s students to mat %s" % \
                                     (struct.code, mat.title))

                            for student in gpe:
                                if matid not in self.students_matieres:
                                    self.students_matieres[matid] = {}
                                self.students_matieres[matid][student.pk] = student
        self.log(logging.INFO, "Getting student matieres : DONE", commit=True)

    def save_student_matieres(self):
        """
        Save student matieres to db.

        """
        self.log(logging.INFO, "Saving students matieres",)
        for studmat in self.students_matieres:
            self.matieres[studmat].update_main_composition(
                self.students_matieres[studmat].values(),
                self.importation.datestart,
                self.importation.dateend,
                self.log)
        self.log(logging.INFO, "Saving students matieres : DONE",)

register_filter("XMLEleves", XMLElevesFilter)
示例#3
0
    def process(self):
        """
        Do importation

        """
        self.log("Getting teachers", logging.INFO, True)
        fmap = {
            'lastname': '{%s}NOM_USAGE' % self.stsns,
            'firstname': '{%s}PRENOM' % self.stsns,
            'ttype': '{%s}TYPE' % self.stsns,
            'code': '{%s}ID' % self.stsns,
        }
        data = {}
        for individu in \
            self.xml["{%s}STS_SERVICES" % self.stsns].\
                findall(".//{%s}DONNEES/{%s}INDIVIDUS/{%s}INDIVIDU" %
                        (self.stsns, self.stsns, self.stsns)):
            data = self._getfmap(individu, fmap)
            self.teachers[data['code']] = Teacher(**data)
            self.teachers[data['code']].norm()
            try:
                Teacher.objects.get(code=data['code'])
                self.log("%s already known" % self.teachers[data['code']])
            except ObjectDoesNotExist:
                self.teachers[data['code']].save()
                self.log("Added %s as NEW" % self.teachers[data['code']])
        self.log("Getting teachers : DONE", logging.INFO, True)

register_filter("STSServices", STSServicesFilter)