Feat: dashboard con gráficos, estructura CBS/Portafolios, semáforo de proyectos y cartera de especialistas
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
import django
|
||||
import sys
|
||||
|
||||
# Set up Django environment
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from expenses.models import Project
|
||||
|
||||
def run_seed():
|
||||
print("Clearing existing projects to ensure clean portfolio seeding...")
|
||||
# This might cascade to expenses, which is expected for seeding a clean MVP/dev environment
|
||||
Project.objects.all().delete()
|
||||
|
||||
print("Seeding Portfolios and Projects...")
|
||||
|
||||
# Portfolio definitions: name and number of projects
|
||||
portfolio_def = {
|
||||
"Portafolio 1": 5,
|
||||
"Portafolio 2": 4,
|
||||
"Portafolio 3": 3,
|
||||
"Portafolio 4": 1,
|
||||
"Portafolio 5": 1,
|
||||
"Portafolio 6": 1,
|
||||
"Portafolio 7": 2,
|
||||
}
|
||||
|
||||
for index, (port_name, num_projects) in enumerate(portfolio_def.items(), 1):
|
||||
port_code = f"PORT-{index:03d}"
|
||||
|
||||
# Create portfolio (parent)
|
||||
portfolio = Project.objects.create(
|
||||
code=port_code,
|
||||
name=port_name,
|
||||
description=f"Portafolio principal para agrupar {num_projects} proyectos contables.",
|
||||
assigned_budget_clp=50000000.00, # 50M base portfolio budget
|
||||
parent=None
|
||||
)
|
||||
print(f"Created Portfolio: {portfolio.code} - {portfolio.name}")
|
||||
|
||||
# Create subprojects
|
||||
for sub_idx in range(1, num_projects + 1):
|
||||
sub_code = f"PRY-{index}{sub_idx:02d}"
|
||||
subproject = Project.objects.create(
|
||||
code=sub_code,
|
||||
name=f"Proyecto {sub_idx} ({port_name})",
|
||||
description=f"Subproyecto contable imputable de {port_name}.",
|
||||
assigned_budget_clp=10000000.00, # 10M base subproject budget
|
||||
parent=portfolio
|
||||
)
|
||||
print(f" Created Project: {subproject.code} - {subproject.name}")
|
||||
|
||||
print("✅ Portfolios and Projects seeding completed successfully.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_seed()
|
||||
Reference in New Issue
Block a user