Esempio n. 1
0
def new():
    if request.method == 'POST':

        form = TeacherCreateForm(request.form)

        if form.is_valid():
            Teacher.create(form.values)
            flash(form.success_message(), 'success')
            return redirect(url_for('teacher_index'))
        else:
            for error in form.error_messages():
                flash(error, 'danger')
            generos = Gender.query.all()
            return render_template(
                'teacher/new.html',
                academic=form.values,
                genders=generos,
            )

    else:
        generos = Gender.query.all()
        return render_template(
            'teacher/new.html',
            academic=None,
            genders=generos,
        )
Esempio n. 2
0
def delete():
    #Auth check
    auth.authenticated_or_401()

    #Chequea permiso
    User.db = get_db()
    if (User.has_permission(session['id'], 'docente_destroy')):
        Teacher.db = get_db()
        Teacher.delete(request.get_json()['teacher_id'])
        response_object = {
            'status': 'success',
            'message': 'Se eliminó el docente'
        }
        return jsonify(response_object)
    else:
        abort(401)
Esempio n. 3
0
def get(id_data):
    #Auth check
    auth.authenticated_or_401()

    #Chequea permiso
    User.db = get_db()
    if (not User.has_permission(session['id'], 'estudiante_show')):
        abort(401)
    else:
        Teacher.db = get_db()
        return jsonify(Teacher.get(id_data))
Esempio n. 4
0
def all():
    #Auth check
    auth.authenticated_or_401()

    #Chequea permiso
    User.db = get_db()
    if (not User.has_permission(session['id'], 'docente_index')):
        abort(401)
    else:
        Teacher.db = get_db()
        return jsonify(Teacher.all_reduced())
Esempio n. 5
0
def index():
	docentes = Teacher.all().items
	localidades = []
	for docente in docentes:
		resp = requests.get(api_localidad.url + "/" + str(docente.localidad_id))
		if resp.status_code != 200:
			localidades.append("Error al obtener la localidad")
		else:
			result = resp.json()
			localidades.append(format(result['nombre']))
	return render_template('docente/index.html', docentes = docentes, localidades = localidades)
Esempio n. 6
0
def update():
    #Auth check
    auth.authenticated_or_401()

    if request.method == "POST":
        #Chequea permiso
        User.db = get_db()
        if (not User.has_permission(session['id'], 'docente_update')):
            abort(401)
        else:
            post_data = request.get_json()
            # if forms.ValidateStudent(request.form).validate():
            Teacher.db = get_db()
            Teacher.update(post_data)
            response_object = {
                'status': 'success',
                'message': 'Se actualizó el docente'
            }
            # else:
            #     response_object = {'status': 'warning', 'message': 'Verifica los campos obligatorios y no ingreses valores no permitidos'}
            return jsonify(response_object)
Esempio n. 7
0
 def get(self):
     filter = {}
     filter["apellido"] = request.args["apellido"] if not None else ""
     filter["numero"] = request.args["numero"] if not None else ""
     search = Teacher.search(filter)
     docentes = []
     for doc in search:
         d = {
             "id": doc.id,
             "nombre": doc.nombre,
             "apellido": doc.apellido,
             "numero": doc.numero
         }
         docentes.append(d)
     return build_response(docentes, search.__len__())
Esempio n. 8
0
def show(id):
	aDocente = Teacher.find_by_id(id)
	resp = requests.get(api_localidad.url)
	localidades = []
	if resp.status_code != 200:
		localidades.append("Error al obtener la localidad")
	else:
		localidades = resp.json()
	generos = Gender.all()

	resp = requests.get(api_tipo_documento.url)
	tiposDoc = []
	if resp.status_code != 200:
		tiposDoc.append("Error al obtener la localidad")
	else:
		tiposDoc = resp.json()
	return render_template('docente/show.html',docente = aDocente,localidades = localidades, generos = generos, tiposDoc = tiposDoc)
Esempio n. 9
0
def delete(id):
	Teacher.delete_by_id(id)
	return redirect (url_for('teacher_index'))
Esempio n. 10
0
def save():
	edit_doc = to_docente(request.form)
	id= request.form.get("id")
	Teacher.update(edit_doc,id)
	return redirect (url_for('teacher_index'))
Esempio n. 11
0
def create():
	if not authenticated(session):
		abort(401)
	new_teacher = to_docente(request.form)
	Teacher.save(new_teacher)
	return redirect(url_for('teacher_index'))