def cadastra_tarefa(request): if request.method == 'POST': form = Form_Cadastro(request.POST) if form.is_valid(): tarefa = Tarefas() tarefa.tarefa = request.POST["tarefa"] tarefa.situacao = False tarefa.save() log = Logs() log.acao = "Insercao" log.data = date.today() log.objeto = tarefa.tarefa log.save() return redirect("/lista_tarefas/") else: form = Form_Cadastro() return render(request, 'cadastra_tarefa.html', { "cadastra_tarefa":form, })
def marca_tarefa(request, id): tarefa = Tarefas.objects.get(pk=id) log = Logs() log.acao = "Marcando tarefa como Concluída" log.data = date.today() log.objeto = id log.save() tarefa.situacao = True tarefa.save() return redirect('/lista_tarefas')