Exemplo n.º 1
0
    def clean(self):

        id_departament = self.cleaned_data.get('id')
        code = self.cleaned_data.get('code')

        if code:
            departament = DepartmentService.find_by_code(code)
            # Al editar puede existir otro departamento con el mismo codigo
            if id_departament:
                if departament.id != id_departament:
                    self.add_error('code', _("There cannot be two certifications with the same code"))
            else:
                if departament:
                    self.add_error('code', _("There cannot be two certifications with the same code"))

        return self.cleaned_data
Exemplo n.º 2
0
def get_form_data_csv(subject):
    data = {}
    if subject:
        data = {
            'name': subject[1],
            'course': subject[2],
            'code': subject[0],
            'quarter': subject[3],
            'credits': subject[4],
            'duration': subject[5],
            'type': subject[6],
        }
        try:
            data['web'] = subject[8]
        except IndexError:
            pass

        department = DepartmentService.find_by_code(subject[7])
        data['departament'] = department.id

    return data
Exemplo n.º 3
0
def get_form_data_csv(subject):
    data = {}
    if subject:
        data = {
            'name': subject[1],
            'course': subject[2],
            'code': subject[0],
            'quarter': subject[3],
            'credits': subject[4],
            'duration': subject[5],
            'type': subject[6],
        }
        try:
            data['web'] = subject[8]
        except IndexError:
            pass

        department = DepartmentService.find_by_code(subject[7])
        data['departament'] = department.id

    return data
Exemplo n.º 4
0
def get_form_data_xml(subject):
    data = {}
    if subject:
        data = {
            'name': subject['nombre'],
            'course': subject['curso'],
            'code': subject['codigo'],
            'quarter': subject['cuatrimestre'],
            'credits': subject['creditos'],
            'duration': subject['duracion'],
            'type': subject['tipo'],
        }

        try:
            data['web'] = subject['web']
        except KeyError:
            pass

        department = DepartmentService.find_by_code(subject['departamento'])
        data['departament'] = department.id

    return data
Exemplo n.º 5
0
    def clean(self):

        id_departament = self.cleaned_data.get('id')
        code = self.cleaned_data.get('code')

        if code:
            departament = DepartmentService.find_by_code(code)
            # Al editar puede existir otro departamento con el mismo codigo
            if id_departament:
                if departament.id != id_departament:
                    self.add_error(
                        'code',
                        _("There cannot be two certifications with the same code"
                          ))
            else:
                if departament:
                    self.add_error(
                        'code',
                        _("There cannot be two certifications with the same code"
                          ))

        return self.cleaned_data
Exemplo n.º 6
0
def get_form_data_xml(subject):
    data = {}
    if subject:
        data = {
            'name': subject['nombre'],
            'course': subject['curso'],
            'code': subject['codigo'],
            'quarter': subject['cuatrimestre'],
            'credits': subject['creditos'],
            'duration': subject['duracion'],
            'type': subject['tipo'],
        }

        try:
            data['web'] = subject['web']
        except KeyError:
            pass

        department = DepartmentService.find_by_code(subject['departamento'])
        data['departament'] = department.id

    return data