fix(v3.4.6): fix reservation cascade, remove calendar mocks, strip auto meet links, friendly dates, dynamic building floors and career filter
This commit is contained in:
@@ -6,7 +6,7 @@ from flask_babel import Babel, gettext as _
|
||||
from config.config import Config
|
||||
|
||||
# Initialize extensions
|
||||
__version__ = "3.4.5"
|
||||
__version__ = "3.4.6"
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
cors = CORS()
|
||||
|
||||
@@ -30,13 +30,24 @@ class Classroom(db.Model):
|
||||
|
||||
@property
|
||||
def floor_display(self):
|
||||
"""Formato amigable para el piso: PB, Planta Baja, Piso X"""
|
||||
"""Formato amigable y dinámico para el piso: PB, EP, Subsuelo, Piso X"""
|
||||
if self.is_virtual:
|
||||
return 'Campus Virtual'
|
||||
f = str(self.floor).strip() if self.floor is not None else ''
|
||||
if f in ['0', 'PB', 'pb', 'Planta Baja', 'planta baja']:
|
||||
return 'Planta Baja'
|
||||
if f.lower().startswith('piso') or '°' in f:
|
||||
if not f:
|
||||
return 'Planta Baja (PB)'
|
||||
f_lower = f.lower()
|
||||
if f in ['0', 'PB', 'pb'] or 'planta baja' in f_lower:
|
||||
return 'Planta Baja (PB)'
|
||||
if f in ['EP', 'ep'] or 'entrepiso' in f_lower:
|
||||
return 'Entrepiso (EP)'
|
||||
if f in ['SS', 'ss'] or 'subsuelo' in f_lower:
|
||||
return f if 'subsuelo' in f_lower else 'Subsuelo (SS)'
|
||||
if f_lower.startswith('piso') or f_lower.startswith('planta') or f_lower.startswith('nivel') or '°' in f:
|
||||
return f
|
||||
return f"Piso {f}"
|
||||
if f.isdigit():
|
||||
return f"Piso {f}"
|
||||
return f
|
||||
|
||||
@property
|
||||
def is_virtual(self):
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.models.role import Role, Permission, SYSTEM_MODULES
|
||||
from app.models.subject import Subject, Commission, CommissionTeacher
|
||||
from app.models.career import Career
|
||||
from app.models.classroom import Classroom
|
||||
from app.models.building import Building
|
||||
from app.models.reservation import Reservation, ReservationStatus
|
||||
from app.models.academic_term import AcademicTerm
|
||||
from app.models.milestone import MilestoneType, AcademicMilestone
|
||||
@@ -218,7 +219,6 @@ def get_commissions():
|
||||
commissions = query.order_by(Commission.id.asc()).all()
|
||||
subjects = Subject.query.order_by(Subject.name.asc()).all()
|
||||
|
||||
from app.models.career import Career
|
||||
careers = Career.query.order_by(Career.name.asc()).all()
|
||||
careers_data = [{'id': cr.id, 'name': cr.name, 'code': cr.code} for cr in careers]
|
||||
|
||||
@@ -938,11 +938,7 @@ def create_commission():
|
||||
if not subject:
|
||||
return jsonify({'error': 'NotFound', 'message': f'La asignatura con ID {subject_id} no existe.'}), 404
|
||||
|
||||
# Generar enlace automático si no fue provisto
|
||||
if not virtual_link:
|
||||
s_clean = re.sub(r'[^a-zA-Z0-9]', '', subject.code).lower()[:6] or 'subj'
|
||||
c_clean = re.sub(r'[^a-zA-Z0-9]', '', code).lower()[:4] or 'c1'
|
||||
virtual_link = f"https://meet.google.com/edu-{s_clean}-{c_clean}"
|
||||
virtual_link = (virtual_link or '').strip() or None
|
||||
|
||||
existing = Commission.query.filter_by(
|
||||
subject_id=int(subject_id),
|
||||
@@ -2518,10 +2514,13 @@ def get_building(id):
|
||||
building = Building.query.get(id)
|
||||
if not building:
|
||||
return jsonify({'error': 'NotFound', 'message': f'Edificio con ID {id} no encontrado.'}), 404
|
||||
classrooms = Classroom.query.filter(
|
||||
db.or_(Classroom.building_id == id, Classroom.building == building.name)
|
||||
).order_by(Classroom.floor.asc(), Classroom.code.asc()).all()
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'building': building.to_dict(),
|
||||
'classrooms': [c.to_dict() for c in building.classrooms]
|
||||
'classrooms': [c.to_dict() for c in classrooms]
|
||||
}), 200
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ OPENAPI_SPEC = {
|
||||
"info": {
|
||||
"title": "Edu-Space REST API",
|
||||
"description": "Enterprise Academic & Physical Space Management REST API with JWT Authentication and Role-Based Access Control.",
|
||||
"version": "3.4.5"
|
||||
"version": "3.4.6"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
|
||||
@@ -86,6 +86,9 @@ def list_reservations():
|
||||
'purpose': r.purpose,
|
||||
'subject_name': r.subject_name,
|
||||
'subject_code': r.subject_code,
|
||||
'career_name': r.commission.career_name if (r.commission and hasattr(r.commission, 'career_name')) else '',
|
||||
'career_names': r.commission.career_names if (r.commission and hasattr(r.commission, 'career_names')) else '',
|
||||
'commission_code': r.commission.code if r.commission else '',
|
||||
'status': str(r.status.value if hasattr(r.status, 'value') else r.status),
|
||||
'shift': r.shift or 'Mañana',
|
||||
'virtual_link': r.virtual_link,
|
||||
|
||||
@@ -269,6 +269,14 @@ class GoogleSheetsImporter:
|
||||
elif h < 13:
|
||||
record_shift = 'Mañana'
|
||||
|
||||
v_link_row = None
|
||||
if len(row) > col_offset + 5:
|
||||
for extra_c in row[col_offset + 5:]:
|
||||
extra_clean = _clean(extra_c)
|
||||
if any(x in extra_clean.lower() for x in ['http://', 'https://', 'zoom.us', 'meet.google.com', 'teams.microsoft.com']):
|
||||
v_link_row = extra_clean
|
||||
break
|
||||
|
||||
records.append({
|
||||
'dia': sheet_name,
|
||||
'codigo': codigo,
|
||||
@@ -276,7 +284,8 @@ class GoogleSheetsImporter:
|
||||
'aula': aula,
|
||||
'carrera': carrera,
|
||||
'horario': horario,
|
||||
'turno': record_shift
|
||||
'turno': record_shift,
|
||||
'virtual_link': v_link_row
|
||||
})
|
||||
return records
|
||||
|
||||
@@ -852,13 +861,10 @@ class GoogleSheetsImporter:
|
||||
if import_reservations and classroom and subject and commission and t_start and t_end:
|
||||
is_room_virtual = bool(classroom.is_virtual or 'VIRTUAL' in (classroom.code or '').upper())
|
||||
|
||||
v_link = None
|
||||
if is_room_virtual:
|
||||
clean_subj = re.sub(r'[^a-zA-Z0-9]', '', subject.code or 'cls').lower()
|
||||
clean_comm = re.sub(r'[^a-zA-Z0-9]', '', commission.code or 'c1').lower()
|
||||
v_link = f"https://meet.google.com/edu-{clean_subj}-{clean_comm}"
|
||||
if not commission.virtual_link:
|
||||
commission.virtual_link = v_link
|
||||
# Respetar estrictamente los datos del Sheet: si no hay enlace explícito en el documento, NO autogenerar ninguno
|
||||
v_link = rec.get('virtual_link') or None
|
||||
if v_link and not commission.virtual_link:
|
||||
commission.virtual_link = v_link
|
||||
|
||||
# Determinar fechas a generar: específica de la fila (datepicker), puntual o 16 semanas
|
||||
dates_to_generate = []
|
||||
@@ -921,7 +927,7 @@ class GoogleSheetsImporter:
|
||||
else:
|
||||
existing_res.shift = turno
|
||||
existing_res.notes = note_text
|
||||
if is_room_virtual and not existing_res.virtual_link:
|
||||
if v_link:
|
||||
existing_res.virtual_link = v_link
|
||||
|
||||
if len(stats['sample_records']) < 15:
|
||||
|
||||
Reference in New Issue
Block a user