From 765688df1f9a0196feece26632d0ad7e1bbd3b55 Mon Sep 17 00:00:00 2001 From: LS Date: Wed, 19 Feb 2025 14:27:14 -0300 Subject: [PATCH] passei os frontends pra bootstrap-flask --- app.py | 14 ++----- templates/base.html | 41 +++++++++++++++++++ templates/home.html | 18 +++++++++ templates/listar_assinaturas.html | 15 +++---- templates/listar_cotas.html | 15 +++---- templates/listar_materiais.html | 15 +++---- templates/listar_militantes.html | 54 +++++++++++++++++-------- templates/listar_pagamentos.html | 16 ++++---- templates/listar_relatorios_cotas.html | 16 ++++---- templates/listar_relatorios_vendas.html | 16 ++++---- templates/listar_vendas_jornal.html | 16 ++++---- templates/nova_assinatura.html | 16 ++++---- templates/nova_cota.html | 16 ++++---- templates/nova_venda_jornal.html | 16 ++++---- templates/novo_material.html | 16 ++++---- templates/novo_militante.html | 17 ++++---- templates/novo_pagamento.html | 16 ++++---- templates/novo_relatorio_cotas.html | 17 ++++---- templates/novo_relatorio_vendas.html | 17 ++++---- 19 files changed, 205 insertions(+), 162 deletions(-) create mode 100644 templates/base.html create mode 100644 templates/home.html diff --git a/app.py b/app.py index 83da760..4a6aabb 100644 --- a/app.py +++ b/app.py @@ -18,11 +18,13 @@ from functions.database import ( from sqlalchemy import create_engine, and_ from sqlalchemy.orm import sessionmaker from datetime import datetime +from flask_bootstrap import Bootstrap5 Session = sessionmaker(bind=engine) session = Session() app = Flask(__name__) +bootstrap = Bootstrap5(app) def session_run(model): @@ -236,19 +238,11 @@ def listar_relatorios_vendas(): def home(): links = [] for rule in app.url_map.iter_rules(): - # Filter out rules we can't navigate to in a browser - # and rules that require parameters if "GET" in rule.methods and has_no_empty_params(rule): url = url_for(rule.endpoint, **(rule.defaults or {})) links.append((url, rule.endpoint)) - l_html = "" - for l in links: - l_html += f'{l[1].replace("_"," ")}
' - home_html = f""" -

Links

- {l_html} - """ - return home_html + + return render_template('home.html', links=links) def has_no_empty_params(rule): diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..f46b591 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,41 @@ + + + + + + {% block title %}{% endblock %} - Sistema de Gestão + {{ bootstrap.load_css() }} + + + + +
+ {% block content %}{% endblock %} +
+ + {{ bootstrap.load_js() }} + + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..31779b9 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,18 @@ +{% extends 'base.html' %} + +{% block title %}Início{% endblock %} + +{% block content %} +
+
+

Menu do Sistema

+
+ {% for url, endpoint in links %} + + {{ endpoint|replace('_', ' ')|title }} + + {% endfor %} +
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/listar_assinaturas.html b/templates/listar_assinaturas.html index 64b2168..b2024d0 100644 --- a/templates/listar_assinaturas.html +++ b/templates/listar_assinaturas.html @@ -1,10 +1,8 @@ - - - - - Listar Assinaturas Anuais - - +{% extends 'base.html' %} + +{% block title %}Início{% endblock %} + +{% block content %}

Assinaturas Anuais

Adicionar Nova Assinatura @@ -34,5 +32,4 @@
Home - - +{% endblock %} \ No newline at end of file diff --git a/templates/listar_cotas.html b/templates/listar_cotas.html index 5dd5760..feddf64 100644 --- a/templates/listar_cotas.html +++ b/templates/listar_cotas.html @@ -1,10 +1,8 @@ - - - - - Listar Cotas Mensais - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Cotas Mensais

Adicionar Nova Cota @@ -30,5 +28,4 @@
Home - - +{% endblock %} diff --git a/templates/listar_materiais.html b/templates/listar_materiais.html index c392f3e..00ff160 100644 --- a/templates/listar_materiais.html +++ b/templates/listar_materiais.html @@ -1,10 +1,8 @@ - - - - - Listar Materiais - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Materiais Vendidos

Adicionar Novo Material @@ -32,5 +30,4 @@
Home - - +{% endblock %} diff --git a/templates/listar_militantes.html b/templates/listar_militantes.html index 77ac145..385168f 100644 --- a/templates/listar_militantes.html +++ b/templates/listar_militantes.html @@ -1,17 +1,37 @@ - - - - - Lista de Militantes - - -

Militantes

- - Adicionar Novo Militante - Home - - \ No newline at end of file +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %} +
+
+

Lista de Militantes

+ Novo Militante + + + + + + + + + + + + + + {% for militante in militantes %} + + + + + + + + + {% endfor %} + +
NomeCPFEmailTelefoneEndereçoFiliado
{{ militante.nome }}{{ militante.cpf }}{{ militante.email }}{{ militante.telefone }}{{ militante.endereco }}{{ 'Sim' if militante.filiado else 'Não' }}
+
+
+{% endblock %} \ No newline at end of file diff --git a/templates/listar_pagamentos.html b/templates/listar_pagamentos.html index c5317bc..30dfe5a 100644 --- a/templates/listar_pagamentos.html +++ b/templates/listar_pagamentos.html @@ -1,10 +1,8 @@ - - - - - Listar Pagamentos - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Pagamentos

Adicionar Novo Pagamento @@ -30,5 +28,5 @@
Home - - +{% endblock %} + diff --git a/templates/listar_relatorios_cotas.html b/templates/listar_relatorios_cotas.html index 1fac21d..85c3558 100644 --- a/templates/listar_relatorios_cotas.html +++ b/templates/listar_relatorios_cotas.html @@ -1,10 +1,8 @@ - - - - - Listar Relatórios de Cotas - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Relatórios de Cotas Mensais

Adicionar Novo Relatório @@ -30,5 +28,5 @@
Home - - +{% endblock %} + diff --git a/templates/listar_relatorios_vendas.html b/templates/listar_relatorios_vendas.html index 63635fa..0694fca 100644 --- a/templates/listar_relatorios_vendas.html +++ b/templates/listar_relatorios_vendas.html @@ -1,10 +1,8 @@ - - - - - Listar Relatórios de Vendas - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Relatórios de Vendas de Materiais

Adicionar Novo Relatório @@ -30,5 +28,5 @@
Home - - + +{% endblock %} diff --git a/templates/listar_vendas_jornal.html b/templates/listar_vendas_jornal.html index d54304f..1916aa9 100644 --- a/templates/listar_vendas_jornal.html +++ b/templates/listar_vendas_jornal.html @@ -1,10 +1,8 @@ - - - - - Listar Vendas de Jornais - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Vendas de Jornais Avulsos

Adicionar Nova Venda @@ -30,5 +28,5 @@
Home - - + +{% endblock %} diff --git a/templates/nova_assinatura.html b/templates/nova_assinatura.html index 3205ce3..9bb99fe 100644 --- a/templates/nova_assinatura.html +++ b/templates/nova_assinatura.html @@ -1,10 +1,8 @@ - - - - - Nova Assinatura Anual - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Nova Assinatura Anual

@@ -35,5 +33,5 @@ Voltar para Lista Home - - + +{% endblock %} diff --git a/templates/nova_cota.html b/templates/nova_cota.html index ece5bcc..0fa224f 100644 --- a/templates/nova_cota.html +++ b/templates/nova_cota.html @@ -1,10 +1,8 @@ - - - - - Nova Cota Mensal - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Nova Cota Mensal

@@ -27,5 +25,5 @@ Voltar para Lista Home - - + +{% endblock %} diff --git a/templates/nova_venda_jornal.html b/templates/nova_venda_jornal.html index 91b6939..c72070c 100644 --- a/templates/nova_venda_jornal.html +++ b/templates/nova_venda_jornal.html @@ -1,10 +1,8 @@ - - - - - Nova Venda de Jornal - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Nova Venda de Jornal

@@ -27,5 +25,5 @@ Voltar para Lista Home - - + +{% endblock %} diff --git a/templates/novo_material.html b/templates/novo_material.html index 1a71b8f..b58b188 100644 --- a/templates/novo_material.html +++ b/templates/novo_material.html @@ -1,10 +1,8 @@ - - - - - Novo Material - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Novo Material

@@ -31,5 +29,5 @@ Voltar para Lista Home - - + +{% endblock %} diff --git a/templates/novo_militante.html b/templates/novo_militante.html index f34c634..14495b2 100644 --- a/templates/novo_militante.html +++ b/templates/novo_militante.html @@ -1,10 +1,8 @@ - - - - - Novo Militante - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Criar Novo Militante

Nome:
@@ -16,5 +14,6 @@
Home - - \ No newline at end of file + +{% endblock %} + diff --git a/templates/novo_pagamento.html b/templates/novo_pagamento.html index 6a32bd9..27bd77a 100644 --- a/templates/novo_pagamento.html +++ b/templates/novo_pagamento.html @@ -1,10 +1,8 @@ - - - - - Novo Pagamento - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Novo Pagamento

@@ -27,5 +25,5 @@ Voltar para Lista Home - - + +{% endblock %} diff --git a/templates/novo_relatorio_cotas.html b/templates/novo_relatorio_cotas.html index 1b5f3e6..2e17576 100644 --- a/templates/novo_relatorio_cotas.html +++ b/templates/novo_relatorio_cotas.html @@ -1,10 +1,8 @@ - - - - - Novo Relatório de Cotas - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Novo Relatório de Cotas

@@ -27,5 +25,6 @@ Voltar para Lista Home - - + +{% endblock %} + diff --git a/templates/novo_relatorio_vendas.html b/templates/novo_relatorio_vendas.html index 03dc8cb..06a55a6 100644 --- a/templates/novo_relatorio_vendas.html +++ b/templates/novo_relatorio_vendas.html @@ -1,10 +1,8 @@ - - - - - Novo Relatório de Vendas - - +{% extends 'base.html' %} + +{% block title %}Listar Militantes{% endblock %} + +{% block content %}

Registrar Novo Relatório de Vendas

@@ -27,5 +25,6 @@ Voltar para Lista Home - - + + +{% endblock %}