feat: melhorias na interface da home e navbar - Ajustes no layout da navbar e menu - Correção do logo e nome do sistema - Melhorias no estilo dos cards da dashboard - Ajustes nas permissões e autenticação - Correção de bugs na exibição de mensagens
This commit is contained in:
57
seed_data.py
57
seed_data.py
@@ -3,7 +3,7 @@ from functions.database import (
|
||||
Base, Militante, CotaMensal, TipoPagamento, Pagamento,
|
||||
MaterialVendido, TipoMaterial, VendaJornalAvulso, AssinaturaAnual,
|
||||
RelatorioCotasMensais, RelatorioVendasMateriais, engine, get_db_connection,
|
||||
Setor, ComiteCentral, Usuario, Role
|
||||
Setor, ComiteCentral, Usuario, Role, EmailMilitante, Endereco
|
||||
)
|
||||
import random
|
||||
from faker import Faker
|
||||
@@ -55,23 +55,56 @@ def criar_militantes(num_militantes):
|
||||
emails_usados.add(email)
|
||||
break
|
||||
|
||||
telefone = fake.phone_number()
|
||||
endereco = fake.address()
|
||||
filiado = fake.boolean()
|
||||
# Criar endereço
|
||||
endereco = Endereco(
|
||||
estado=fake.estado_sigla(),
|
||||
cidade=fake.city(),
|
||||
bairro=fake.bairro(),
|
||||
rua=fake.street_name(),
|
||||
numero=str(random.randint(1, 999)),
|
||||
complemento=f"Bloco {random.randint(1, 10)}, Apto {random.randint(1, 999)}" if random.random() < 0.3 else None,
|
||||
cep=fake.postcode()
|
||||
)
|
||||
db_session.add(endereco)
|
||||
db_session.flush() # Para obter o ID do endereço
|
||||
|
||||
print(f"Criando militante {i+1}: {nome} (CPF: {cpf})")
|
||||
|
||||
# Criar militante
|
||||
militante = Militante(
|
||||
nome=nome,
|
||||
cpf=cpf,
|
||||
email=email,
|
||||
telefone=telefone,
|
||||
endereco=endereco,
|
||||
filiado=filiado
|
||||
titulo_eleitoral=str(random.randint(100000000000, 999999999999)),
|
||||
data_nascimento=fake.date_of_birth(minimum_age=18, maximum_age=65),
|
||||
data_entrada_oci=fake.date_between(start_date='-5y', end_date='today'),
|
||||
data_efetivacao_oci=fake.date_between(start_date='-4y', end_date='today'),
|
||||
telefone1=fake.phone_number(),
|
||||
telefone2=fake.phone_number() if random.random() < 0.3 else None,
|
||||
profissao=fake.job(),
|
||||
regime_trabalho=random.choice(['CLT', 'PJ', 'Estatutário', 'Autônomo']),
|
||||
empresa=fake.company(),
|
||||
contratante=fake.company() if random.random() < 0.2 else None,
|
||||
instituicao_ensino=fake.company() if random.random() < 0.4 else None,
|
||||
tipo_instituicao=random.choice(['Federal', 'Estadual', 'Municipal', 'Privada']) if random.random() < 0.4 else None,
|
||||
sindicato=fake.company() if random.random() < 0.6 else None,
|
||||
cargo_sindical=random.choice(['Diretor', 'Delegado', 'Conselheiro']) if random.random() < 0.3 else None,
|
||||
dirigente_sindical=random.random() < 0.2,
|
||||
central_sindical=random.choice(['CUT', 'CSP-Conlutas', 'CTB', 'Força Sindical']) if random.random() < 0.4 else None,
|
||||
endereco_id=endereco.id,
|
||||
responsabilidades=random.randint(0, 1023) # Valor aleatório para responsabilidades
|
||||
)
|
||||
db_session.add(militante)
|
||||
db_session.flush() # Para obter o ID do militante
|
||||
|
||||
# Criar email do militante
|
||||
email_militante = EmailMilitante(
|
||||
militante_id=militante.id,
|
||||
endereco_email=email
|
||||
)
|
||||
db_session.add(email_militante)
|
||||
|
||||
militantes.append(militante)
|
||||
|
||||
db_session.add_all(militantes)
|
||||
db_session.commit()
|
||||
return militantes
|
||||
|
||||
@@ -98,14 +131,14 @@ def criar_cotas(militantes, quantidade_por_militante=3):
|
||||
|
||||
def criar_pagamentos(militantes):
|
||||
"""Cria pagamentos fictícios"""
|
||||
tipos_pagamento = db_session.query(TipoPagamento).all()
|
||||
tipos_pagamento = ["Cota", "Jornal", "Assinatura", "Campanha Financeira"]
|
||||
for militante in militantes:
|
||||
for _ in range(random.randint(1, 5)):
|
||||
pagamento = Pagamento(
|
||||
militante_id=militante.id,
|
||||
tipo_pagamento_id=random.choice(tipos_pagamento).id,
|
||||
tipo_pagamento=random.choice(tipos_pagamento),
|
||||
valor=random.uniform(50, 500),
|
||||
data_pagamento=fake.date_time_between(start_date='-1y', end_date='now')
|
||||
data_pagamento=fake.date_between(start_date='-1y', end_date='today')
|
||||
)
|
||||
db_session.add(pagamento)
|
||||
db_session.commit()
|
||||
|
||||
Reference in New Issue
Block a user