41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
|
|
from flask import Blueprint, render_template, redirect, url_for
|
||
|
|
from flask_login import login_required
|
||
|
|
|
||
|
|
from functions.decorators import require_login
|
||
|
|
from controllers.home_controller import HomeController
|
||
|
|
|
||
|
|
main_bp = Blueprint('main', __name__)
|
||
|
|
|
||
|
|
@main_bp.route("/")
|
||
|
|
@require_login
|
||
|
|
def index():
|
||
|
|
"""Rota principal - redireciona para home se autenticado"""
|
||
|
|
return redirect(url_for('main.home'))
|
||
|
|
|
||
|
|
@main_bp.route("/home")
|
||
|
|
@require_login
|
||
|
|
def home():
|
||
|
|
"""Página inicial do sistema com dashboard"""
|
||
|
|
dashboard_data = HomeController.dashboard()
|
||
|
|
return render_template('home.html',
|
||
|
|
nome_usuario=dashboard_data['nome_usuario'],
|
||
|
|
data_atual=dashboard_data['data_atual'],
|
||
|
|
total_militantes=dashboard_data['total_militantes'],
|
||
|
|
total_cotas=dashboard_data['total_cotas'],
|
||
|
|
total_materiais=dashboard_data['total_materiais'],
|
||
|
|
total_assinaturas=dashboard_data['total_assinaturas'],
|
||
|
|
ultimos_militantes=dashboard_data['ultimos_militantes'],
|
||
|
|
ultimos_pagamentos=dashboard_data['ultimos_pagamentos'],
|
||
|
|
tipos_pagamento=dashboard_data['tipos_pagamento'],
|
||
|
|
Militante=None) # Militante class for constants
|
||
|
|
|
||
|
|
@main_bp.route("/api/setores/<int:cr_id>")
|
||
|
|
@require_login
|
||
|
|
def get_setores(cr_id):
|
||
|
|
"""API para listar setores por comitê regional"""
|
||
|
|
from services.setor_service import SetorService
|
||
|
|
|
||
|
|
setores = SetorService.listar_setores_por_cr(cr_id)
|
||
|
|
return jsonify({
|
||
|
|
'setores': [{'id': s.id, 'nome': s.nome} for s in setores]
|
||
|
|
})
|