feat: implementar ABM completo de comisiones, carreras y asignaturas con proteccion de integridad y corregir edificios y campus virtual

This commit is contained in:
2026-09-23 19:53:27 -03:00
parent 195bfd915e
commit 165a0b65b8
13 changed files with 1033 additions and 154 deletions
+37 -3
View File
@@ -17,10 +17,40 @@ class Building(db.Model):
# Relationships
classrooms = db.relationship('Classroom', backref='building_entity', lazy=True, foreign_keys='Classroom.building_id')
@property
def is_virtual(self):
"""Identifica si la sede corresponde al Campus Virtual"""
c = (self.code or '').upper()
n = (self.name or '').upper()
return 'VIRTUAL' in c or 'VIRTUAL' in n
@property
def physical_capacity(self):
"""Capacidad física instalada real (excluye aulas virtuales con capacidad 9999 o infinitas)"""
if self.is_virtual:
return 0
return sum(c.capacity for c in self.classrooms if c.is_active and (c.capacity or 0) < 999 and not getattr(c, 'is_virtual', False))
@property
def total_capacity(self):
"""Total student capacity across active classrooms in this building"""
return sum(c.capacity for c in self.classrooms if c.is_active)
"""Capacidad para compatibilidad histórica"""
if self.is_virtual:
return 0
return self.physical_capacity
@property
def capacity_display(self):
"""Representación textual clara para UI/UX"""
if self.is_virtual:
return "Ilimitada (Virtual)"
return str(self.physical_capacity)
@property
def floors_display(self):
"""Representación de pisos"""
if self.is_virtual:
return "Digital"
return str(self.floors)
@property
def classrooms_count(self):
@@ -34,10 +64,14 @@ class Building(db.Model):
'code': self.code,
'address': self.address,
'floors': self.floors,
'floors_display': self.floors_display,
'description': self.description,
'is_active': self.is_active,
'is_virtual': self.is_virtual,
'classrooms_count': self.classrooms_count,
'total_capacity': self.total_capacity,
'physical_capacity': self.physical_capacity,
'total_capacity': self.physical_capacity if not self.is_virtual else 0,
'capacity_display': self.capacity_display,
'created_at': self.created_at.isoformat() if self.created_at else None
}