예제 #1
0
 def post(self):
     args = self.reqparse.parse_args()
     token = args.get('auth-token')
     alumno = Alumno.load_from_token(token)
     apoderado = Apoderado.load_from_token(token)
     administrador = Administrador.load_from_token(token)
     profesor = Profesor.load_from_token(token)
     if alumno == None and apoderado == None and administrador == None and profesor == None:
         return {'response': 'user_invalid'}, 401
     data = request.data.decode()
     data = json.loads(data)
     profesor = Profesor()
     profesor.nombres = data['nombres']
     profesor.apellido_paterno = data['apellido_paterno']
     profesor.apellido_materno = data['apellido_materno']
     profesor.telefono = data['telefono']
     profesor.email = data['email']
     profesor.encrypt_password(data['rut'])
     profesor.rut = data['rut']
     direccion = Direccion(calle=data['calle'],
                           numero=data['numero'],
                           comuna=data['comuna'],
                           cas_dep_of=data['cas_dep_of'])
     profesor.direccion = direccion
     asignatura = Asignatura.objects(id=data['asignatura']).first()
     profesor.asignatura = asignatura.id
     profesor.save()
     return {'Response': 'exito', 'id': str(profesor.id)}
예제 #2
0
 def post(self):
     args = self.reqparse.parse_args()
     token = args.get('auth-token')
     userAdmin = Administrador.load_from_token(token)
     userAlum = Alumno.load_from_token(token)
     userProf = Profesor.load_from_token(token)
     if userAdmin == None and userAlum == None and userProf == None:
         return {'response': 'user_invalid'}, 401
     institucion = None
     if userAdmin != None:
         institucion = Institucion.objects(
             id=userAdmin.institucion.id).first()
     if userAlum != None:
         institucion = Institucion.objects(
             id=userAlum.institucion.id).first()
     if userProf != None:
         institucion = Institucion.objects(
             id=userProf.institucion.id).first()
     if institucion == None:
         return {'response': 'colegio_invalid'}, 404
     data = request.data.decode()
     data = json.loads(data)
     profesor = Profesor()
     profesor.nombres = data['nombres']
     profesor.apellido_paterno = data['apellido_paterno']
     profesor.apellido_materno = data['apellido_materno']
     profesor.telefono = data['telefono']
     profesor.email = data['email']
     profesor.nombre_usuario = data['nombre_usuario']
     profesor.encrypt_password(data['nombre_usuario'])
     profesor.institucion = institucion.id
     profesor.save()
     return {'Response': 'exito', 'id': str(profesor.id)}
예제 #3
0
 def post(self, id_institucion):
     data = request.data.decode()
     data = json.loads(data)
     profesor = Profesor()
     profesor.nombres = data['nombres']
     profesor.apellido_paterno = data['apellido_paterno']
     profesor.apellido_materno = data['apellido_materno']
     profesor.telefono = data['telefono']
     profesor.email = data['email']
     profesor.nombre_usuario = data['nombre_usuario']
     profesor.password = data['nombre_usuario']
     institucion = Institucion.objects(id=id_institucion).first()
     profesor.institucion = institucion.id
     profesor.save()
     return {'Response': 'exito', 'id': str(profesor.id)}
예제 #4
0
 def post(self, token):
     data = request.data.decode()
     data = json.loads(data)
     token = token
     if Administrador.load_from_token(token) != None:
         profesor = Profesor()
         profesor.nombres = data['nombres']
         profesor.apellido_paterno = data['apellido_paterno']
         profesor.apellido_materno = data['apellido_materno']
         profesor.telefono = data['telefono']
         profesor.email = data['email']
         profesor.nombre_usuario = data['nombre_usuario']
         profesor.encrypt_password(data['nombre_usuario'])
         profesor.save()
         return {'Response': 'exito', 'id': str(profesor.id)}
     else:
         return {'Response': 'fracaso'}