def newTask(): consulta = """ SELECT id, name, apellidos FROM empleados; """ empleados = dbQuery(consulta) mychoices = [(-1, 'Seleccione Empleado')] + [ (e['id'], '{} {}'.format(e['name'], e['apellidos'])) for e in empleados ] form = TaskForm(request.form) form.updateChoices(mychoices) if request.method == 'GET': return render_template("task.html", form=form) if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') id_employee = request.values.get('id_employee') if id_employee == '-1': id_employee == None consulta = """ INSERT INTO tareas (titulo, descripcion, fecha, id_empleado) VALUES (?, ?, ?, ?); """ dbQuery(consulta, title, desc, fx, id_employee) return redirect(url_for("index")) else: return render_template("task.html", form=form)
def newTask(): form = TaskForm(request.form) if request.method == 'GET': return render_template("task.html", form=form) if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') addTask(title, desc, fx) return redirect(url_for('index')) #Va a redirigir a index. else: return render_template("task.html", form=form)
def newTask(): form = TaskForm(request.form) if request.method == 'GET': return render_template("task.html", form=form) if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') #Para ficheros # addTask(title, desc, fx) addTaskDB(title, desc, fx) return redirect(url_for("index")) else: return render_template("task.html", form=form)
def newTask(): form = TaskForm(request.form) if request.method == 'GET': return render_template("task.html", form=form) if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') dbQuery( """INSERT INTO tareas (titulo, descripción, date) VALUES (?,?,?);""", title, desc, fx) return redirect(url_for('index')) #Va a redirigir a index. else: return render_template("task.html", form=form)
def newTask(): form = TaskForm(request.form) if request.method == 'GET': return render_template("task.html", form=form) if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') consulta = """ INSERT INTO tareas (titulo, descripcion, fecha) VALUES (?, ?, ?); """ dbQuery(consulta, title, desc, fx) return redirect(url_for("index")) else: return render_template("task.html", form=form)
def newTask(): form = TaskForm(request.form) if request.method == 'GET': #request es una instancia de repeticion que nos pide el servidor return render_template("task.html", form=form) #render_template es para plantillas if form.validate(): title = request.values.get('title') desc = request.values.get('description') fx = request.values.get('fx') consulta = ''' INSERT INTO tareas (titulo, descripcion, fecha) VALUES(?, ?, ?); ''' dbQuery(consulta, title, desc, fx) return redirect(url_for("index")) #esto redirige a index else: return render_template( "task.html", form=form ) #return render_template("task.html") #una vez hecho todo el if, al darle a enviar, creará una carpeta en "data"