Melhorada interface dos formulários. Adicionado a opção de editar os Militantes direto da Lista
This commit is contained in:
68
app.py
68
app.py
@@ -1,5 +1,4 @@
|
|||||||
from flask import Flask, request, render_template, redirect, url_for
|
from flask import Flask, request, render_template, redirect, url_for, flash
|
||||||
from functions.database import execute_query
|
|
||||||
from functions.database import (
|
from functions.database import (
|
||||||
Base,
|
Base,
|
||||||
Militante,
|
Militante,
|
||||||
@@ -19,11 +18,14 @@ from sqlalchemy import create_engine, and_
|
|||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask_bootstrap import Bootstrap5
|
from flask_bootstrap import Bootstrap5
|
||||||
|
from routes.cota import cota_bp
|
||||||
|
from functions.validations import validar_cpf
|
||||||
|
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
session = Session()
|
session = Session()
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.secret_key = 'sua_chave_secreta_aqui'
|
||||||
bootstrap = Bootstrap5(app)
|
bootstrap = Bootstrap5(app)
|
||||||
|
|
||||||
|
|
||||||
@@ -40,17 +42,24 @@ def session_run(model):
|
|||||||
@app.route("/militantes/novo", methods=["GET", "POST"])
|
@app.route("/militantes/novo", methods=["GET", "POST"])
|
||||||
def novo_militante():
|
def novo_militante():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
cpf = request.form["cpf"]
|
||||||
|
|
||||||
|
if not validar_cpf(cpf):
|
||||||
|
flash('CPF inválido. Por favor, verifique o número informado.', 'error')
|
||||||
|
return render_template("novo_militante.html",
|
||||||
|
dados_anteriores=request.form)
|
||||||
|
|
||||||
novo_militante = Militante(
|
novo_militante = Militante(
|
||||||
nome=request.form["nome"],
|
nome=request.form["nome"],
|
||||||
cpf=request.form["cpf"],
|
cpf=cpf,
|
||||||
email=request.form["email"],
|
email=request.form["email"],
|
||||||
telefone=request.form["telefone"],
|
telefone=request.form["telefone"],
|
||||||
endereco=request.form["endereco"],
|
endereco=request.form["endereco"],
|
||||||
filiado=request.form.get("filiado", False),
|
filiado=bool(request.form.get("filiado", False))
|
||||||
)
|
)
|
||||||
|
|
||||||
session_run(novo_militante)
|
session_run(novo_militante)
|
||||||
# execute_query(query, (nome, cpf, email, telefone, endereco, filiado))
|
flash('Militante cadastrado com sucesso!', 'success')
|
||||||
return redirect(url_for("listar_militantes"))
|
return redirect(url_for("listar_militantes"))
|
||||||
|
|
||||||
return render_template("novo_militante.html")
|
return render_template("novo_militante.html")
|
||||||
@@ -147,7 +156,7 @@ def nova_venda_jornal():
|
|||||||
data_venda=datetime.strptime(request.form["data_venda"], "%Y-%m-%d"),
|
data_venda=datetime.strptime(request.form["data_venda"], "%Y-%m-%d"),
|
||||||
)
|
)
|
||||||
|
|
||||||
session_run(VendaJornalAvulso)
|
session_run(vendas_jornais_avulsos)
|
||||||
return redirect(url_for("listar_vendas_jornal"))
|
return redirect(url_for("listar_vendas_jornal"))
|
||||||
|
|
||||||
return render_template("nova_venda_jornal.html")
|
return render_template("nova_venda_jornal.html")
|
||||||
@@ -236,11 +245,14 @@ def listar_relatorios_vendas():
|
|||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
|
"""Página inicial do sistema"""
|
||||||
links = []
|
links = []
|
||||||
for rule in app.url_map.iter_rules():
|
for rule in app.url_map.iter_rules():
|
||||||
if "GET" in rule.methods and has_no_empty_params(rule):
|
if "GET" in rule.methods and has_no_empty_params(rule):
|
||||||
url = url_for(rule.endpoint, **(rule.defaults or {}))
|
url = url_for(rule.endpoint, **(rule.defaults or {}))
|
||||||
links.append((url, rule.endpoint))
|
# Substituindo 'home' por 'início' no menu
|
||||||
|
endpoint_name = 'Início' if rule.endpoint == 'home' else rule.endpoint
|
||||||
|
links.append((url, endpoint_name))
|
||||||
|
|
||||||
return render_template('home.html', links=links)
|
return render_template('home.html', links=links)
|
||||||
|
|
||||||
@@ -251,6 +263,48 @@ def has_no_empty_params(rule):
|
|||||||
return len(defaults) >= len(arguments)
|
return len(defaults) >= len(arguments)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/militantes/editar/<int:id>", methods=["GET", "POST"])
|
||||||
|
def editar_militante(id):
|
||||||
|
militante = session.query(Militante).get(id)
|
||||||
|
if not militante:
|
||||||
|
flash('Militante não encontrado.', 'error')
|
||||||
|
return redirect(url_for('listar_militantes'))
|
||||||
|
|
||||||
|
if request.method == "POST":
|
||||||
|
cpf = request.form["cpf"]
|
||||||
|
if cpf != militante.cpf and not validar_cpf(cpf): # Só valida se o CPF foi alterado
|
||||||
|
flash('CPF inválido. Por favor, verifique o número informado.', 'error')
|
||||||
|
return render_template("editar_militante.html", militante=militante)
|
||||||
|
|
||||||
|
try:
|
||||||
|
militante.nome = request.form["nome"]
|
||||||
|
militante.cpf = cpf
|
||||||
|
militante.email = request.form["email"]
|
||||||
|
militante.telefone = request.form["telefone"]
|
||||||
|
militante.endereco = request.form["endereco"]
|
||||||
|
militante.filiado = bool(request.form.get("filiado", False))
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
flash('Militante atualizado com sucesso!', 'success')
|
||||||
|
return redirect(url_for('listar_militantes'))
|
||||||
|
except Exception as e:
|
||||||
|
session.rollback()
|
||||||
|
flash('Erro ao atualizar militante. Verifique se o CPF ou email já não estão cadastrados.', 'error')
|
||||||
|
return render_template("editar_militante.html", militante=militante)
|
||||||
|
|
||||||
|
return render_template("editar_militante.html", militante=militante)
|
||||||
|
|
||||||
|
|
||||||
|
def create_app():
|
||||||
|
app = Flask(__name__)
|
||||||
|
# ... existing code ...
|
||||||
|
|
||||||
|
app.register_blueprint(cota_bp)
|
||||||
|
|
||||||
|
# ... existing code ...
|
||||||
|
return app
|
||||||
|
|
||||||
|
|
||||||
# Iniciar o servidor Flask
|
# Iniciar o servidor Flask
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|||||||
@@ -1,39 +1,31 @@
|
|||||||
import mysql.connector
|
|
||||||
from mysql.connector import Error
|
|
||||||
# from config.db_config import db_config
|
|
||||||
from sqlalchemy import create_engine, Column, Integer, String, Boolean, Numeric, Date, ForeignKey
|
from sqlalchemy import create_engine, Column, Integer, String, Boolean, Numeric, Date, ForeignKey
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship, sessionmaker
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
engine = create_engine('sqlite:///database.db', echo=True)
|
engine = create_engine('sqlite:///database.db', echo=True)
|
||||||
Base = declarative_base()
|
SessionLocal = sessionmaker(bind=engine)
|
||||||
|
|
||||||
def get_db_connection(db_config):
|
def get_db_connection():
|
||||||
try:
|
"""
|
||||||
connection = mysql.connector.connect(**db_config)
|
Retorna uma nova sessão do banco de dados
|
||||||
return connection
|
"""
|
||||||
except Error as e:
|
return SessionLocal()
|
||||||
print(f"Error connecting to database: {e}")
|
|
||||||
return None
|
|
||||||
|
|
||||||
def execute_query(query, params=None):
|
def execute_query(query, params=None):
|
||||||
connection = get_db_connection('')
|
"""
|
||||||
if connection is None:
|
Executa uma query usando SQLAlchemy
|
||||||
return None
|
"""
|
||||||
|
session = get_db_connection()
|
||||||
try:
|
try:
|
||||||
cursor = connection.cursor(dictionary=True)
|
result = session.execute(query, params)
|
||||||
cursor.execute(query, params)
|
session.commit()
|
||||||
connection.commit()
|
return result
|
||||||
return cursor
|
except Exception as e:
|
||||||
except Error as e:
|
session.rollback()
|
||||||
print(f"Error executing query: {e}")
|
raise e
|
||||||
return None
|
|
||||||
finally:
|
finally:
|
||||||
if connection.is_connected():
|
session.close()
|
||||||
cursor.close()
|
|
||||||
connection.close()
|
|
||||||
|
|
||||||
class Militante(Base):
|
class Militante(Base):
|
||||||
__tablename__ = 'militantes'
|
__tablename__ = 'militantes'
|
||||||
|
|||||||
34
functions/validations.py
Normal file
34
functions/validations.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
def validar_cpf(cpf):
|
||||||
|
"""
|
||||||
|
Valida um CPF seguindo as regras do governo brasileiro.
|
||||||
|
Retorna True se o CPF é válido, False caso contrário.
|
||||||
|
"""
|
||||||
|
# Remove caracteres não numéricos
|
||||||
|
cpf = ''.join(filter(str.isdigit, cpf))
|
||||||
|
|
||||||
|
# Verifica se tem 11 dígitos
|
||||||
|
if len(cpf) != 11:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Verifica se todos os dígitos são iguais
|
||||||
|
if len(set(cpf)) == 1:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Calcula primeiro dígito verificador
|
||||||
|
soma = 0
|
||||||
|
for i in range(9):
|
||||||
|
soma += int(cpf[i]) * (10 - i)
|
||||||
|
resto = soma % 11
|
||||||
|
digito1 = 0 if resto < 2 else 11 - resto
|
||||||
|
|
||||||
|
if int(cpf[9]) != digito1:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Calcula segundo dígito verificador
|
||||||
|
soma = 0
|
||||||
|
for i in range(10):
|
||||||
|
soma += int(cpf[i]) * (11 - i)
|
||||||
|
resto = soma % 11
|
||||||
|
digito2 = 0 if resto < 2 else 11 - resto
|
||||||
|
|
||||||
|
return int(cpf[10]) == digito2
|
||||||
24
models/integracao.py
Normal file
24
models/integracao.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
def calcular_cota(salary, num_children, pays_school, pays_rent, num_parents):
|
||||||
|
"""
|
||||||
|
Calcula o valor da cota baseado nos parâmetros fornecidos
|
||||||
|
"""
|
||||||
|
# Base da cota é 1% do salário
|
||||||
|
cota_base = salary * 0.01
|
||||||
|
|
||||||
|
# Adiciona 0.5% por filho
|
||||||
|
cota_filhos = (salary * 0.005) * num_children
|
||||||
|
|
||||||
|
# Adiciona 0.3% por pai/mãe dependente
|
||||||
|
cota_pais = (salary * 0.003) * num_parents
|
||||||
|
|
||||||
|
# Reduz 0.2% se paga escola
|
||||||
|
reducao_escola = (salary * 0.002) if pays_school else 0
|
||||||
|
|
||||||
|
# Reduz 0.2% se paga aluguel
|
||||||
|
reducao_aluguel = (salary * 0.002) if pays_rent else 0
|
||||||
|
|
||||||
|
# Calcula cota final
|
||||||
|
cota_final = cota_base + cota_filhos + cota_pais - reducao_escola - reducao_aluguel
|
||||||
|
|
||||||
|
# Garante que a cota não seja menor que 0.5% do salário
|
||||||
|
return max(cota_final, salary * 0.005)
|
||||||
30
routes/cota.py
Normal file
30
routes/cota.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
from flask import Blueprint, request, jsonify
|
||||||
|
from models.integracao import calcular_cota
|
||||||
|
|
||||||
|
cota_bp = Blueprint('cota', __name__)
|
||||||
|
|
||||||
|
@cota_bp.route('/calculate_cota', methods=['POST'])
|
||||||
|
def calculate_cota():
|
||||||
|
try:
|
||||||
|
data = request.get_json()
|
||||||
|
|
||||||
|
# Extrair dados do request
|
||||||
|
salary = float(data.get('salary', 0))
|
||||||
|
num_children = int(data.get('num_children', 0))
|
||||||
|
pays_school = bool(data.get('pays_school', False))
|
||||||
|
pays_rent = bool(data.get('pays_rent', False))
|
||||||
|
num_parents = int(data.get('num_parents', 0))
|
||||||
|
|
||||||
|
# Calcular a cota (implemente sua lógica de cálculo aqui)
|
||||||
|
cota = calcular_cota(
|
||||||
|
salary=salary,
|
||||||
|
num_children=num_children,
|
||||||
|
pays_school=pays_school,
|
||||||
|
pays_rent=pays_rent,
|
||||||
|
num_parents=num_parents
|
||||||
|
)
|
||||||
|
|
||||||
|
return jsonify({'cota': cota})
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({'error': str(e)}), 400
|
||||||
@@ -38,4 +38,4 @@
|
|||||||
|
|
||||||
{{ bootstrap.load_js() }}
|
{{ bootstrap.load_js() }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
34
templates/editar_militante.html
Normal file
34
templates/editar_militante.html
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Editar Militante{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Editar Militante</h1>
|
||||||
|
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<div class="alert alert-{{ category }}">{{ message }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
Nome: <input type="text" name="nome" required
|
||||||
|
value="{{ militante.nome }}"><br>
|
||||||
|
CPF: <input type="text" name="cpf" required
|
||||||
|
value="{{ militante.cpf }}"
|
||||||
|
pattern="\d{3}\.?\d{3}\.?\d{3}-?\d{2}"
|
||||||
|
title="Digite um CPF no formato: xxx.xxx.xxx-xx"><br>
|
||||||
|
Email: <input type="email" name="email" required
|
||||||
|
value="{{ militante.email }}"><br>
|
||||||
|
Telefone: <input type="text" name="telefone"
|
||||||
|
value="{{ militante.telefone }}"><br>
|
||||||
|
Endereço: <input type="text" name="endereco"
|
||||||
|
value="{{ militante.endereco }}"><br>
|
||||||
|
Filiado: <input type="checkbox" name="filiado"
|
||||||
|
{% if militante.filiado %}checked{% endif %}><br>
|
||||||
|
<input type="submit" value="Salvar" class="btn btn-primary">
|
||||||
|
<a href="{{ url_for('listar_militantes') }}" class="btn btn-secondary">Cancelar</a>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<h2>Lista de Militantes</h2>
|
<h2>Lista de Militantes</h2>
|
||||||
<a href="{{ url_for('novo_militante') }}" class="btn btn-primary mb-3">Novo Militante</a>
|
<a href="{{ url_for('novo_militante') }}" class="btn btn-primary mb-3">Novo Militante</a>
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Nome</th>
|
<th>Nome</th>
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for militante in militantes %}
|
{% for militante in militantes %}
|
||||||
<tr>
|
<tr class="clickable-row" data-href="{{ url_for('editar_militante', id=militante.id) }}">
|
||||||
<td>{{ militante.nome }}</td>
|
<td>{{ militante.nome }}</td>
|
||||||
<td>{{ militante.cpf }}</td>
|
<td>{{ militante.cpf }}</td>
|
||||||
<td>{{ militante.email }}</td>
|
<td>{{ militante.email }}</td>
|
||||||
@@ -34,4 +34,24 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.clickable-row {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.clickable-row:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
const rows = document.querySelectorAll('.clickable-row');
|
||||||
|
rows.forEach(row => {
|
||||||
|
row.addEventListener('click', function() {
|
||||||
|
window.location.href = this.dataset.href;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -29,9 +29,11 @@
|
|||||||
<label for="data_fim">Data de Fim:</label>
|
<label for="data_fim">Data de Fim:</label>
|
||||||
<input type="date" id="data_fim" name="data_fim" required>
|
<input type="date" id="data_fim" name="data_fim" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Registrar Assinatura</button>
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Registrar</button>
|
||||||
|
<a href="{{ url_for('listar_assinaturas') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<a href="{{ url_for('listar_assinaturas') }}">Voltar para Lista</a>
|
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -21,9 +21,11 @@
|
|||||||
<label for="data_alteracao">Data de Alteração:</label>
|
<label for="data_alteracao">Data de Alteração:</label>
|
||||||
<input type="date" id="data_alteracao" name="data_alteracao" required>
|
<input type="date" id="data_alteracao" name="data_alteracao" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Registrar Cota</button>
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Registrar</button>
|
||||||
|
<a href="{{ url_for('listar_cotas') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<a href="{{ url_for('listar_cotas') }}">Voltar para Lista</a>
|
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -21,9 +21,11 @@
|
|||||||
<label for="data_venda">Data da Venda:</label>
|
<label for="data_venda">Data da Venda:</label>
|
||||||
<input type="date" id="data_venda" name="data_venda" required>
|
<input type="date" id="data_venda" name="data_venda" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Registrar Venda</button>
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Registrar</button>
|
||||||
|
<a href="{{ url_for('listar_vendas_jornal') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<a href="{{ url_for('listar_vendas_jornal') }}">Voltar para Lista</a>
|
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -25,9 +25,11 @@
|
|||||||
<label for="data_venda">Data da Venda:</label>
|
<label for="data_venda">Data da Venda:</label>
|
||||||
<input type="date" id="data_venda" name="data_venda" required>
|
<input type="date" id="data_venda" name="data_venda" required>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit">Registrar Material</button>
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Registrar</button>
|
||||||
|
<a href="{{ url_for('listar_materiais') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<a href="{{ url_for('listar_materiais') }}">Voltar para Lista</a>
|
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,19 +1,68 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Listar Militantes{% endblock %}
|
{% block title %}Novo Militante{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Criar Novo Militante</h1>
|
<div class="container">
|
||||||
<form method="post">
|
<div class="row">
|
||||||
Nome: <input type="text" name="nome" required><br>
|
<div class="col-md-8 offset-md-2">
|
||||||
CPF: <input type="text" name="cpf" required><br>
|
<h1 class="mb-4">Criar Novo Militante</h1>
|
||||||
Email: <input type="email" name="email" required><br>
|
|
||||||
Telefone: <input type="text" name="telefone"><br>
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
Endereço: <input type="text" name="endereco"><br>
|
{% if messages %}
|
||||||
Filiado: <input type="checkbox" name="filiado"><br>
|
{% for category, message in messages %}
|
||||||
<input type="submit" value="Criar">
|
<div class="alert alert-{{ category }}">{{ message }}</div>
|
||||||
</form>
|
{% endfor %}
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<form method="post" class="mb-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="nome" class="form-label">Nome:</label>
|
||||||
|
<input type="text" class="form-control" id="nome" name="nome" required
|
||||||
|
value="{{ dados_anteriores.nome if dados_anteriores else '' }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="cpf" class="form-label">CPF:</label>
|
||||||
|
<input type="text" class="form-control" id="cpf" name="cpf" required
|
||||||
|
value="{{ dados_anteriores.cpf if dados_anteriores else '' }}"
|
||||||
|
pattern="\d{3}\.?\d{3}\.?\d{3}-?\d{2}"
|
||||||
|
title="Digite um CPF no formato: xxx.xxx.xxx-xx">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">Email:</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="email" required
|
||||||
|
value="{{ dados_anteriores.email if dados_anteriores else '' }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="telefone" class="form-label">Telefone:</label>
|
||||||
|
<input type="text" class="form-control" id="telefone" name="telefone"
|
||||||
|
value="{{ dados_anteriores.telefone if dados_anteriores else '' }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="endereco" class="form-label">Endereço:</label>
|
||||||
|
<input type="text" class="form-control" id="endereco" name="endereco"
|
||||||
|
value="{{ dados_anteriores.endereco if dados_anteriores else '' }}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" id="filiado" name="filiado"
|
||||||
|
{% if dados_anteriores and dados_anteriores.filiado %}checked{% endif %}>
|
||||||
|
<label class="form-check-label" for="filiado">Filiado</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Criar</button>
|
||||||
|
<a href="{{ url_for('listar_militantes') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,41 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Listar Militantes{% endblock %}
|
{% block title %}Novo Pagamento{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Registrar Novo Pagamento</h1>
|
<div class="container">
|
||||||
<form method="post">
|
<div class="row">
|
||||||
<div>
|
<div class="col-md-8 offset-md-2">
|
||||||
<label for="militante_id">ID do Militante:</label>
|
<h1 class="mb-4">Registrar Novo Pagamento</h1>
|
||||||
<input type="number" id="militante_id" name="militante_id" required>
|
|
||||||
|
<form method="post" class="mb-4">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="militante_id" class="form-label">ID do Militante:</label>
|
||||||
|
<input type="number" class="form-control" id="militante_id" name="militante_id" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="tipo_pagamento_id" class="form-label">Tipo de Pagamento:</label>
|
||||||
|
<input type="number" class="form-control" id="tipo_pagamento_id" name="tipo_pagamento_id" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="valor" class="form-label">Valor:</label>
|
||||||
|
<input type="number" class="form-control" id="valor" name="valor" step="0.01" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="data_pagamento" class="form-label">Data do Pagamento:</label>
|
||||||
|
<input type="date" class="form-control" id="data_pagamento" name="data_pagamento" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex gap-2">
|
||||||
|
<button type="submit" class="btn btn-primary">Registrar</button>
|
||||||
|
<a href="{{ url_for('listar_pagamentos') }}" class="btn btn-secondary">Voltar</a>
|
||||||
|
<a href="{{ url_for('home') }}" class="btn btn-outline-primary">Início</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
<label for="tipo_pagamento_id">Tipo de Pagamento:</label>
|
</div>
|
||||||
<input type="number" id="tipo_pagamento_id" name="tipo_pagamento_id" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="valor">Valor:</label>
|
|
||||||
<input type="number" id="valor" name="valor" step="0.01" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="data_pagamento">Data do Pagamento:</label>
|
|
||||||
<input type="date" id="data_pagamento" name="data_pagamento" required>
|
|
||||||
</div>
|
|
||||||
<button type="submit">Registrar Pagamento</button>
|
|
||||||
</form>
|
|
||||||
<a href="{{ url_for('listar_pagamentos') }}">Voltar para Lista</a>
|
|
||||||
<a href="{{ url_for('home') }}">Home</a>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user