示例#1
0
def exibirDietaBuscado(id):
    form = {}
    refeicoes = Refeicao.autocomplete()
    try:
        dieta = Dieta.get_by_id(id)
        return render_template('/Dieta/AlterarCadastrarDieta.html', **locals())
    except Exception as e:
        return u"" + str(e)
示例#2
0
def exibirRefeicaoBuscado(id):
    form = {}
    alimentos = Alimento.autocomplete()
    refeicoes = Refeicao.autocomplete()
    try:
        refeicao = Refeicao.select().where(Refeicao.id_refeicao == id).get()
        return render_template('/Refeicao/CadastrarAlterar.html', **locals())
    except Exception as e:
        return u"" + str(e)
示例#3
0
def alterar(id):
    try:
        form = {}
        refeicoes = Refeicao.autocomplete()
        dieta = Dieta.select().where(Dieta.id_dieta == id).get()
        rd = Refeicoes_Dieta.select().where(Refeicoes_Dieta.id_dieta == id)
        return render_template('/Dieta/AlterarCadastrarDieta.html', **locals())
    except Exception as e:
        return u"" + str(e)
示例#4
0
def RemoverRefeicaoDieta(id_dieta, id):
    refeicoes = Refeicao.autocomplete()
    try:
        rd = Refeicoes_Dieta.select().where(
            Refeicoes_Dieta.id_dieta == int(id_dieta)
            and Refeicoes_Dieta.id_refeicao == id).get()
        rd.delete_instance()
        msg = "Alimento deletado da refeicao com sucesso!"
        return redirect('/Dieta/ExibirDietaAlterar/%d/' % int(id_dieta))
    except Exception as e:
        return u"" + str(e)
示例#5
0
def AlterarRefeicao():
    try:
        refeicoes = Refeicao.autocomplete()
        nome = request.args.get('busca')
        if nome:
            refeicao = Refeicao.buscar(nome)
            return redirect("/Refeicao/ExibirRefeicaoAlterar/%d/" % refeicao)
        else:
            return render_template('/Refeicao/BuscaRefeicaoAlterar.html',
                                   **locals())
    except Exception as e:
        return u"" + str(e)
示例#6
0
def RemoverRefeicao(id):
    refeicoes = Refeicao.autocomplete()
    try:
        id_ref = int(id)
        Refeicao.delete_by_id(id_ref)
        ar = Alimentos_Refeicao.select().where(
            Alimentos_Refeicao.id_refeicao == int(id_ref)
            and Alimentos_Refeicao.id_alimento == id).get()
        ar.delete_instance()

        msg = "Refeicao deletada com sucesso!"
        return redirect('/Refeicao/ListarRefeicoes/')
    except Exception as e:
        return u"" + str(e)
示例#7
0
def RemoverAlimentoRefeicao(id_refeicao, id):
    refeicoes = Refeicao.autocomplete()
    try:
        ar = Alimentos_Refeicao.select().where(
            Alimentos_Refeicao.id_refeicao == int(id_refeicao)
            and Alimentos_Refeicao.id_alimento == id).get()
        ar.delete_instance()
        msg = "Alimento deletado da refeicao com sucesso!"
        return redirect('/Refeicao/ExibirRefeicaoAlterar/%d/' %
                        int(id_refeicao))
    except Exception as e:
        return u"" + str(e)


##Refeicao##
示例#8
0
def RemoverDieta(id):
    refeicoes = Refeicao.autocomplete()
    try:
        id_diet = int(id)

        rd = Refeicoes_Dieta.select().where(
            Refeicoes_Dieta.id_dieta == id_diet).get()
        rd.delete_instance()
        d = Dieta.select().where(Dieta.id_dieta == id_diet).get()
        d.delete_instance()

        msg = "Refeicao deletada com sucesso!"
        return redirect('/Dieta/ListarDietas/')
    except Exception as e:
        return u"" + str(e)
示例#9
0
def adicionaRefeicaoDieta(id_dieta):
    refeicoes = Refeicao.autocomplete()
    form = request.form.to_dict()
    dieta = Dieta.get_by_id(int(id_dieta))
    r = request.args.get('busca')
    if r:
        try:
            refeicao = Refeicao.select().where(
                Refeicao.nome_refeicao == r).get()
            if refeicao is not None:
                rd = Refeicoes_Dieta()
                rd.id_refeicao = refeicao.id_refeicao
                rd.id_dieta = id_dieta
                rd.save()
                return redirect('/Dieta/CadastroDieta/%s/' % id_dieta)
            else:
                msg = "Alimento nao encontrado!"

        except Exception as e:
            return e
    else:
        return render_template("/Dieta/AlterarCadastrarDieta.html",
                               Diet=Dieta,
                               **locals())
示例#10
0
def BuscaListaRefeicoes():
    refeicoes = Refeicao.autocomplete()
    return render_template('/Refeicao/Exibir.html', **locals())