passei os frontends pra bootstrap-flask

This commit is contained in:
LS
2025-02-19 14:27:14 -03:00
parent eff8c531d7
commit 765688df1f
19 changed files with 205 additions and 162 deletions

14
app.py
View File

@@ -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'<a href="{l[0]}">{l[1].replace("_"," ")}</a><br>'
home_html = f"""
<p>Links</p>
{l_html}
"""
return home_html
return render_template('home.html', links=links)
def has_no_empty_params(rule):

41
templates/base.html Normal file
View File

@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}{% endblock %} - Sistema de Gestão</title>
{{ bootstrap.load_css() }}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="{{ url_for('home') }}">Sistema de Gestão</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{{ url_for('listar_militantes') }}">Militantes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('listar_cotas') }}">Cotas</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('listar_pagamentos') }}">Pagamentos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('listar_materiais') }}">Materiais</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
{% block content %}{% endblock %}
</div>
{{ bootstrap.load_js() }}
</body>
</html>

18
templates/home.html Normal file
View File

@@ -0,0 +1,18 @@
{% extends 'base.html' %}
{% block title %}Início{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h2>Menu do Sistema</h2>
<div class="list-group">
{% for url, endpoint in links %}
<a href="{{ url }}" class="list-group-item list-group-item-action">
{{ endpoint|replace('_', ' ')|title }}
</a>
{% endfor %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Assinaturas Anuais</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Início{% endblock %}
{% block content %}
<h1>Assinaturas Anuais</h1>
<a href="{{ url_for('nova_assinatura') }}">Adicionar Nova Assinatura</a>
<table border="1">
@@ -34,5 +32,4 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Cotas Mensais</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Cotas Mensais</h1>
<a href="{{ url_for('nova_cota') }}">Adicionar Nova Cota</a>
<table border="1">
@@ -30,5 +28,4 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Materiais</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Materiais Vendidos</h1>
<a href="{{ url_for('novo_material') }}">Adicionar Novo Material</a>
<table border="1">
@@ -32,5 +30,4 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,17 +1,37 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Lista de Militantes</title>
</head>
<body>
<h1>Militantes</h1>
<ul>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h2>Lista de Militantes</h2>
<a href="{{ url_for('novo_militante') }}" class="btn btn-primary mb-3">Novo Militante</a>
<table class="table table-striped">
<thead>
<tr>
<th>Nome</th>
<th>CPF</th>
<th>Email</th>
<th>Telefone</th>
<th>Endereço</th>
<th>Filiado</th>
</tr>
</thead>
<tbody>
{% for militante in militantes %}
<li>{{ militante.nome }} - {{ militante.email }}</li>
<tr>
<td>{{ militante.nome }}</td>
<td>{{ militante.cpf }}</td>
<td>{{ militante.email }}</td>
<td>{{ militante.telefone }}</td>
<td>{{ militante.endereco }}</td>
<td>{{ 'Sim' if militante.filiado else 'Não' }}</td>
</tr>
{% endfor %}
</ul>
<a href="{{ url_for('novo_militante') }}">Adicionar Novo Militante</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
</tbody>
</table>
</div>
</div>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Pagamentos</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Pagamentos</h1>
<a href="{{ url_for('novo_pagamento') }}">Adicionar Novo Pagamento</a>
<table border="1">
@@ -30,5 +28,5 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Relatórios de Cotas</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Relatórios de Cotas Mensais</h1>
<a href="{{ url_for('novo_relatorio_cotas') }}">Adicionar Novo Relatório</a>
<table border="1">
@@ -30,5 +28,5 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Relatórios de Vendas</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Relatórios de Vendas de Materiais</h1>
<a href="{{ url_for('novo_relatorio_vendas') }}">Adicionar Novo Relatório</a>
<table border="1">
@@ -30,5 +28,5 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Listar Vendas de Jornais</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Vendas de Jornais Avulsos</h1>
<a href="{{ url_for('nova_venda_jornal') }}">Adicionar Nova Venda</a>
<table border="1">
@@ -30,5 +28,5 @@
</tbody>
</table>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Nova Assinatura Anual</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Nova Assinatura Anual</h1>
<form method="post">
<div>
@@ -35,5 +33,5 @@
</form>
<a href="{{ url_for('listar_assinaturas') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Nova Cota Mensal</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Nova Cota Mensal</h1>
<form method="post">
<div>
@@ -27,5 +25,5 @@
</form>
<a href="{{ url_for('listar_cotas') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Nova Venda de Jornal</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Nova Venda de Jornal</h1>
<form method="post">
<div>
@@ -27,5 +25,5 @@
</form>
<a href="{{ url_for('listar_vendas_jornal') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Novo Material</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Novo Material</h1>
<form method="post">
<div>
@@ -31,5 +29,5 @@
</form>
<a href="{{ url_for('listar_materiais') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Novo Militante</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Criar Novo Militante</h1>
<form method="post">
Nome: <input type="text" name="nome" required><br>
@@ -16,5 +14,6 @@
<input type="submit" value="Criar">
</form>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Novo Pagamento</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Novo Pagamento</h1>
<form method="post">
<div>
@@ -27,5 +25,5 @@
</form>
<a href="{{ url_for('listar_pagamentos') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Novo Relatório de Cotas</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Novo Relatório de Cotas</h1>
<form method="post">
<div>
@@ -27,5 +25,6 @@
</form>
<a href="{{ url_for('listar_relatorios_cotas') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}

View File

@@ -1,10 +1,8 @@
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Novo Relatório de Vendas</title>
</head>
<body>
{% extends 'base.html' %}
{% block title %}Listar Militantes{% endblock %}
{% block content %}
<h1>Registrar Novo Relatório de Vendas</h1>
<form method="post">
<div>
@@ -27,5 +25,6 @@
</form>
<a href="{{ url_for('listar_relatorios_vendas') }}">Voltar para Lista</a>
<a href="{{ url_for('home') }}">Home</a>
</body>
</html>
{% endblock %}