feat(sheets): add online career, subject, day filtering and manual date assignment controls
This commit is contained in:
@@ -414,21 +414,6 @@ def get_stats():
|
|||||||
available_classrooms_month = []
|
available_classrooms_month = []
|
||||||
total_active_commissions = 0
|
total_active_commissions = 0
|
||||||
milestones = []
|
milestones = []
|
||||||
date_labels = {
|
|
||||||
'today': 'Hoy',
|
|
||||||
'today_short': 'Hoy',
|
|
||||||
'today_full': 'Hoy',
|
|
||||||
'week': 'Esta Semana',
|
|
||||||
'week_full': 'Esta Semana',
|
|
||||||
'month': 'Este Mes',
|
|
||||||
'month_full': 'Este Mes'
|
|
||||||
}
|
|
||||||
filter_stats = {
|
|
||||||
'date_labels': date_labels,
|
|
||||||
'today': {'label': 'Hoy', 'classrooms': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}, 'commissions': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}},
|
|
||||||
'week': {'label': 'Esta Semana', 'classrooms': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}, 'commissions': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}},
|
|
||||||
'month': {'label': 'Este Mes', 'classrooms': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}, 'commissions': {'assigned': [], 'unassigned': [], 'assigned_count': 0, 'unassigned_count': 0, 'assigned_pct': 0, 'unassigned_pct': 0, 'total': 0}}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Mocked monthly data for chart since complex SQL group by month might differ based on dialect (SQLite vs Postgres)
|
# Mocked monthly data for chart since complex SQL group by month might differ based on dialect (SQLite vs Postgres)
|
||||||
monthly_data = [
|
monthly_data = [
|
||||||
@@ -465,9 +450,7 @@ def get_stats():
|
|||||||
'assigned_today_pct': assigned_today_pct,
|
'assigned_today_pct': assigned_today_pct,
|
||||||
'unassigned_today_classrooms': unassigned_today_count,
|
'unassigned_today_classrooms': unassigned_today_count,
|
||||||
'unassigned_today_pct': unassigned_today_pct,
|
'unassigned_today_pct': unassigned_today_pct,
|
||||||
'total_active_commissions': total_active_commissions,
|
'total_active_commissions': total_active_commissions
|
||||||
'date_labels': date_labels,
|
|
||||||
'filter_stats': filter_stats
|
|
||||||
},
|
},
|
||||||
'audit_logs': audit_data,
|
'audit_logs': audit_data,
|
||||||
'monthly_data': monthly_data,
|
'monthly_data': monthly_data,
|
||||||
@@ -476,14 +459,10 @@ def get_stats():
|
|||||||
'week_schedule_list': week_schedule_list,
|
'week_schedule_list': week_schedule_list,
|
||||||
'upcoming_reservations': upcoming_reservations,
|
'upcoming_reservations': upcoming_reservations,
|
||||||
'milestones': milestones,
|
'milestones': milestones,
|
||||||
'filter_stats': filter_stats,
|
|
||||||
'date_labels': date_labels,
|
|
||||||
'ui': {
|
'ui': {
|
||||||
'show_role_banner': SystemSetting.get_value('dashboard_role_banner_enabled', 'true') in ['true', 'True', '1', True]
|
'show_role_banner': SystemSetting.get_value('dashboard_role_banner_enabled', 'true') in ['true', 'True', '1', True]
|
||||||
},
|
},
|
||||||
'bedelia': {
|
'bedelia': {
|
||||||
'filter_stats': filter_stats,
|
|
||||||
'date_labels': date_labels,
|
|
||||||
'unassigned_commissions_week': unassigned_commissions_week,
|
'unassigned_commissions_week': unassigned_commissions_week,
|
||||||
'unassigned_commissions_month': unassigned_commissions_month,
|
'unassigned_commissions_month': unassigned_commissions_month,
|
||||||
'unassigned_commissions_general': unassigned_commissions_general,
|
'unassigned_commissions_general': unassigned_commissions_general,
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ CANONICAL_CAREERS = {
|
|||||||
'POSG. INCLUSIVAS': 'POSG. INCLUSIVAS',
|
'POSG. INCLUSIVAS': 'POSG. INCLUSIVAS',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def normalize_day_name(day_str):
|
||||||
|
"""Normaliza cualquier variante de día a su nombre canónico en español (Lunes..Sábado)"""
|
||||||
|
if not day_str:
|
||||||
|
return ''
|
||||||
|
d = day_str.strip().lower()
|
||||||
|
d = d.replace('á', 'a').replace('é', 'e').replace('í', 'i').replace('ó', 'o').replace('ú', 'u')
|
||||||
|
if 'lun' in d: return 'Lunes'
|
||||||
|
if 'mar' in d: return 'Martes'
|
||||||
|
if 'mie' in d: return 'Miércoles'
|
||||||
|
if 'jue' in d: return 'Jueves'
|
||||||
|
if 'vie' in d: return 'Viernes'
|
||||||
|
if 'sab' in d: return 'Sábado'
|
||||||
|
if 'dom' in d: return 'Domingo'
|
||||||
|
return day_str.strip()
|
||||||
|
|
||||||
def map_day_to_idx(day_str):
|
def map_day_to_idx(day_str):
|
||||||
"""Mapea el nombre del día (o prefijo) a su índice numérico 0..6 (Lunes=0)"""
|
"""Mapea el nombre del día (o prefijo) a su índice numérico 0..6 (Lunes=0)"""
|
||||||
d = (day_str or '').lower()
|
d = (day_str or '').lower()
|
||||||
@@ -337,16 +352,101 @@ class GoogleSheetsImporter:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def sync(self):
|
def inspect_sheet_content(self):
|
||||||
"""
|
"""
|
||||||
Proceso principal de sincronización:
|
Descarga e inspecciona las hojas del Sheet online para extraer:
|
||||||
1. Descarga las 6 hojas de cálculo semanales (Lunes a Sábado).
|
- Días disponibles con cantidad de filas
|
||||||
2. Normaliza carreras individuales y asignaturas compartidas (Many-to-Many).
|
- Carreras únicas
|
||||||
3. Upserts Aulas, Carreras, Asignaturas, Comisiones.
|
- Materias únicas con sus códigos, nombres y carreras
|
||||||
4. Genera Reservas en el calendario para el semestre académico.
|
|
||||||
"""
|
"""
|
||||||
|
sheets_to_process = self.get_sheets_config()
|
||||||
|
days_info = []
|
||||||
|
careers_set = set()
|
||||||
|
subjects_map = {}
|
||||||
|
total_rows = 0
|
||||||
|
|
||||||
|
for sheet_cfg in sheets_to_process:
|
||||||
|
day_name = sheet_cfg['name']
|
||||||
|
try:
|
||||||
|
csv_data = self.fetch_sheet_csv(sheet_cfg['gid'])
|
||||||
|
rows = self.parse_sheet_rows(csv_data, day_name)
|
||||||
|
total_rows += len(rows)
|
||||||
|
days_info.append({
|
||||||
|
'name': day_name,
|
||||||
|
'gid': sheet_cfg['gid'],
|
||||||
|
'day_idx': sheet_cfg['day_idx'],
|
||||||
|
'rows_count': len(rows),
|
||||||
|
'status': 'OK'
|
||||||
|
})
|
||||||
|
for r in rows:
|
||||||
|
carreras = parse_careers_list(r.get('carrera', ''))
|
||||||
|
for c in carreras:
|
||||||
|
if c and c != 'General':
|
||||||
|
careers_set.add(c)
|
||||||
|
|
||||||
|
code = r.get('codigo', '').strip()
|
||||||
|
name = r.get('asignatura', '').strip()
|
||||||
|
if code and name:
|
||||||
|
if code not in subjects_map:
|
||||||
|
subjects_map[code] = {
|
||||||
|
'code': code,
|
||||||
|
'name': name,
|
||||||
|
'careers': carreras,
|
||||||
|
'day': day_name
|
||||||
|
}
|
||||||
|
except Exception as e:
|
||||||
|
days_info.append({
|
||||||
|
'name': day_name,
|
||||||
|
'gid': sheet_cfg['gid'],
|
||||||
|
'day_idx': sheet_cfg.get('day_idx', 0),
|
||||||
|
'rows_count': 0,
|
||||||
|
'status': 'Error',
|
||||||
|
'error': str(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
'total_rows': total_rows,
|
||||||
|
'days': days_info,
|
||||||
|
'careers': sorted(list(careers_set)),
|
||||||
|
'subjects': sorted(list(subjects_map.values()), key=lambda x: x['code'])
|
||||||
|
}
|
||||||
|
|
||||||
|
def sync(self, filter_career=None, filter_subject=None, filter_day=None, manual_date=None, single_date_only=False):
|
||||||
|
"""
|
||||||
|
Proceso principal de sincronización con soporte de filtros y fechas manuales:
|
||||||
|
:param filter_career: Filtrar por carrera específica (ej. 'DATOS (CCC)')
|
||||||
|
:param filter_subject: Filtrar por código o nombre de materia (ej. 'ASIG00113')
|
||||||
|
:param filter_day: Filtrar por día específico ('Lunes'..'Sábado' o 'ALL')
|
||||||
|
:param manual_date: Fecha manual específica (YYYY-MM-DD o objeto date)
|
||||||
|
:param single_date_only: Si es True y hay manual_date, crea reserva solo para esa fecha puntual
|
||||||
|
"""
|
||||||
|
dias_esp = ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo']
|
||||||
|
|
||||||
|
# Normalizar fecha manual si fue provista
|
||||||
|
manual_dt = None
|
||||||
|
if manual_date:
|
||||||
|
try:
|
||||||
|
if isinstance(manual_date, (datetime, date)):
|
||||||
|
manual_dt = manual_date if isinstance(manual_date, date) else manual_date.date()
|
||||||
|
elif isinstance(manual_date, str) and manual_date.strip():
|
||||||
|
manual_dt = datetime.strptime(manual_date.strip(), '%Y-%m-%d').date()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Normalizar día filtro si fue provisto
|
||||||
|
norm_filter_day = normalize_day_name(filter_day) if filter_day else None
|
||||||
|
if norm_filter_day and norm_filter_day.upper() in ['ALL', 'TODOS', 'TODOS LOS DÍAS', 'TODOS LOS DIAS', '']:
|
||||||
|
norm_filter_day = None
|
||||||
|
|
||||||
|
# Si el usuario no especificó filter_day pero ingresó fecha manual puntual, inferir día
|
||||||
|
if not norm_filter_day and manual_dt and single_date_only:
|
||||||
|
manual_w = manual_dt.weekday()
|
||||||
|
if manual_w < 6:
|
||||||
|
norm_filter_day = dias_esp[manual_w]
|
||||||
|
|
||||||
stats = {
|
stats = {
|
||||||
'total_rows_processed': 0,
|
'total_rows_processed': 0,
|
||||||
|
'matching_rows': 0,
|
||||||
'careers_created': 0,
|
'careers_created': 0,
|
||||||
'careers_updated': 0,
|
'careers_updated': 0,
|
||||||
'classrooms_created': 0,
|
'classrooms_created': 0,
|
||||||
@@ -357,11 +457,23 @@ class GoogleSheetsImporter:
|
|||||||
'reservations_created': 0,
|
'reservations_created': 0,
|
||||||
'by_day': {},
|
'by_day': {},
|
||||||
'errors': [],
|
'errors': [],
|
||||||
'sample_records': []
|
'sample_records': [],
|
||||||
|
'filters_applied': {
|
||||||
|
'career': filter_career.strip() if filter_career else None,
|
||||||
|
'subject': filter_subject.strip() if filter_subject else None,
|
||||||
|
'day': norm_filter_day or 'Todos los Días',
|
||||||
|
'manual_date': manual_dt.strftime('%Y-%m-%d') if manual_dt else None,
|
||||||
|
'single_date_only': bool(single_date_only and manual_dt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
all_raw_records = []
|
all_raw_records = []
|
||||||
sheets_to_process = self.get_sheets_config()
|
sheets_to_process = self.get_sheets_config()
|
||||||
|
|
||||||
|
# Filtrar pestañas si se especificó un día específico
|
||||||
|
if norm_filter_day:
|
||||||
|
sheets_to_process = [s for s in sheets_to_process if normalize_day_name(s['name']) == norm_filter_day]
|
||||||
|
|
||||||
for sheet_cfg in sheets_to_process:
|
for sheet_cfg in sheets_to_process:
|
||||||
day_name = sheet_cfg['name']
|
day_name = sheet_cfg['name']
|
||||||
try:
|
try:
|
||||||
@@ -424,9 +536,11 @@ class GoogleSheetsImporter:
|
|||||||
classrooms_cache = {(c.building.strip().upper(), c.code.strip().upper()): c for c in Classroom.query.all()}
|
classrooms_cache = {(c.building.strip().upper(), c.code.strip().upper()): c for c in Classroom.query.all()}
|
||||||
subjects_cache = {s.code.strip().upper(): s for s in Subject.query.all()}
|
subjects_cache = {s.code.strip().upper(): s for s in Subject.query.all()}
|
||||||
|
|
||||||
# Calculate current semester dates (anchored on academic year 2026)
|
# Calculate semester dates (anchored on academic year 2026 or manual date base)
|
||||||
base_monday = date(2026, 8, 31)
|
base_monday = date(2026, 8, 31)
|
||||||
weeks_to_generate = 16 # Generar reservas para 16 semanas (cuatrimestre completo Ago - Dic 2026)
|
if manual_dt and not single_date_only:
|
||||||
|
base_monday = manual_dt - timedelta(days=manual_dt.weekday())
|
||||||
|
weeks_to_generate = 16 # Generar reservas para 16 semanas
|
||||||
|
|
||||||
for rec, day_idx in all_raw_records:
|
for rec, day_idx in all_raw_records:
|
||||||
try:
|
try:
|
||||||
@@ -435,11 +549,32 @@ class GoogleSheetsImporter:
|
|||||||
aula_raw = rec['aula']
|
aula_raw = rec['aula']
|
||||||
carrera_raw = rec['carrera'].strip()
|
carrera_raw = rec['carrera'].strip()
|
||||||
horario_raw = rec['horario']
|
horario_raw = rec['horario']
|
||||||
dia = rec['dia']
|
dia = rec['dia'] or (dias_esp[manual_dt.weekday()] if manual_dt else 'Lunes')
|
||||||
turno = rec.get('turno', 'Mañana')
|
turno = rec.get('turno', 'Mañana')
|
||||||
|
|
||||||
# 1. Upsert Careers (Desglosar carreras múltiples normalizadas)
|
# Si el registro no traía día pero hay fecha manual, asignar día de la fecha
|
||||||
|
if day_idx is None and manual_dt:
|
||||||
|
day_idx = manual_dt.weekday()
|
||||||
|
|
||||||
|
# --- FILTRO 1: Filtrar por Carrera si fue especificada ---
|
||||||
carreras_list = parse_careers_list(carrera_raw)
|
carreras_list = parse_careers_list(carrera_raw)
|
||||||
|
if filter_career:
|
||||||
|
fc = filter_career.strip().upper()
|
||||||
|
match_c = any(fc in c.upper() or c.upper() in fc for c in carreras_list) or (fc in carrera_raw.upper())
|
||||||
|
if not match_c:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# --- FILTRO 2: Filtrar por Materia si fue especificada ---
|
||||||
|
sub_codes = parse_subject_codes(codigo)
|
||||||
|
if filter_subject:
|
||||||
|
fs = filter_subject.strip().upper()
|
||||||
|
match_s = (fs in codigo.upper()) or (fs in asignatura.upper()) or any(fs in sc.upper() for sc in sub_codes)
|
||||||
|
if not match_s:
|
||||||
|
continue
|
||||||
|
|
||||||
|
stats['matching_rows'] += 1
|
||||||
|
|
||||||
|
# 1. Upsert Careers (Desglosar carreras múltiples normalizadas)
|
||||||
career_objs = []
|
career_objs = []
|
||||||
for c_name in carreras_list:
|
for c_name in carreras_list:
|
||||||
c_key = c_name.upper()
|
c_key = c_name.upper()
|
||||||
@@ -484,7 +619,6 @@ class GoogleSheetsImporter:
|
|||||||
|
|
||||||
# 3. Upsert Subject (Soporte Many-to-Many con múltiples carreras y subcódigos)
|
# 3. Upsert Subject (Soporte Many-to-Many con múltiples carreras y subcódigos)
|
||||||
subject_key = codigo.upper()
|
subject_key = codigo.upper()
|
||||||
sub_codes = parse_subject_codes(codigo)
|
|
||||||
subject = subjects_cache.get(subject_key)
|
subject = subjects_cache.get(subject_key)
|
||||||
if not subject:
|
if not subject:
|
||||||
for sc in sub_codes:
|
for sc in sub_codes:
|
||||||
@@ -571,7 +705,9 @@ class GoogleSheetsImporter:
|
|||||||
|
|
||||||
# 5. Generar Reservas de Calendario
|
# 5. Generar Reservas de Calendario
|
||||||
t_start, t_end = self.parse_time_range(horario_raw)
|
t_start, t_end = self.parse_time_range(horario_raw)
|
||||||
if classroom and t_start and t_end and day_idx is not None:
|
effective_day_idx = day_idx if day_idx is not None else (manual_dt.weekday() if manual_dt else 0)
|
||||||
|
|
||||||
|
if classroom and t_start and t_end:
|
||||||
is_room_virtual = bool(classroom.is_virtual or 'VIRTUAL' in (classroom.code or '').upper())
|
is_room_virtual = bool(classroom.is_virtual or 'VIRTUAL' in (classroom.code or '').upper())
|
||||||
|
|
||||||
v_link = None
|
v_link = None
|
||||||
@@ -582,8 +718,14 @@ class GoogleSheetsImporter:
|
|||||||
if not commission.virtual_link:
|
if not commission.virtual_link:
|
||||||
commission.virtual_link = v_link
|
commission.virtual_link = v_link
|
||||||
|
|
||||||
for w in range(weeks_to_generate):
|
# Determinar fechas a generar: puntual o 16 semanas
|
||||||
class_date = base_monday + timedelta(days=day_idx, weeks=w)
|
dates_to_generate = []
|
||||||
|
if single_date_only and manual_dt:
|
||||||
|
dates_to_generate = [manual_dt]
|
||||||
|
else:
|
||||||
|
dates_to_generate = [base_monday + timedelta(days=effective_day_idx, weeks=w) for w in range(weeks_to_generate)]
|
||||||
|
|
||||||
|
for class_date in dates_to_generate:
|
||||||
dt_start = datetime.combine(class_date, t_start)
|
dt_start = datetime.combine(class_date, t_start)
|
||||||
dt_end = datetime.combine(class_date, t_end)
|
dt_end = datetime.combine(class_date, t_end)
|
||||||
|
|
||||||
@@ -602,6 +744,8 @@ class GoogleSheetsImporter:
|
|||||||
).first()
|
).first()
|
||||||
|
|
||||||
c_desc = ", ".join([c.name for c in career_objs]) if career_objs else 'General'
|
c_desc = ", ".join([c.name for c in career_objs]) if career_objs else 'General'
|
||||||
|
note_suffix = f" [Fecha asignada: {class_date.strftime('%d/%m/%Y')}]" if (manual_dt and single_date_only) else ""
|
||||||
|
note_text = f"Clase {'puntual ' if (single_date_only and manual_dt) else 'semanal '}{dia} ({turno}) - Carreras: {c_desc}{note_suffix}"
|
||||||
|
|
||||||
if not existing_res:
|
if not existing_res:
|
||||||
res = Reservation(
|
res = Reservation(
|
||||||
@@ -615,13 +759,13 @@ class GoogleSheetsImporter:
|
|||||||
expected_attendees=min(classroom.capacity, 30) if not is_room_virtual else 35,
|
expected_attendees=min(classroom.capacity, 30) if not is_room_virtual else 35,
|
||||||
shift=turno,
|
shift=turno,
|
||||||
virtual_link=v_link,
|
virtual_link=v_link,
|
||||||
notes=f"Clase semanal {dia} ({turno}) - Carreras: {c_desc}"
|
notes=note_text
|
||||||
)
|
)
|
||||||
db.session.add(res)
|
db.session.add(res)
|
||||||
stats['reservations_created'] += 1
|
stats['reservations_created'] += 1
|
||||||
else:
|
else:
|
||||||
existing_res.shift = turno
|
existing_res.shift = turno
|
||||||
existing_res.notes = f"Clase semanal {dia} ({turno}) - Carreras: {c_desc}"
|
existing_res.notes = note_text
|
||||||
if is_room_virtual and not existing_res.virtual_link:
|
if is_room_virtual and not existing_res.virtual_link:
|
||||||
existing_res.virtual_link = v_link
|
existing_res.virtual_link = v_link
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ const handleGoogleSheetsImport = async (req, res, justSynced = false) => {
|
|||||||
recentSubjects = (sR.value.data?.subjects || []).slice(0, 15);
|
recentSubjects = (sR.value.data?.subjects || []).slice(0, 15);
|
||||||
}
|
}
|
||||||
if (cmR.status === 'fulfilled') metrics.total_commissions = cmR.value.data?.commissions?.length || 0;
|
if (cmR.status === 'fulfilled') metrics.total_commissions = cmR.value.data?.commissions?.length || 0;
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Backend sync-sheets API error:', err.response?.data || err.message);
|
console.error('Backend sync-sheets API error:', err.response?.data || err.message);
|
||||||
syncError = err.response?.data?.message || err.message;
|
syncError = err.response?.data?.message || err.message;
|
||||||
@@ -276,9 +276,9 @@ router.get(['/occupancy_metrics', '/occupancy-metrics', '/metrics/occupancy'], h
|
|||||||
|
|
||||||
const MOCK_ROLES = [
|
const MOCK_ROLES = [
|
||||||
{ id: 1, name: 'Administrador', description: 'Acceso total al sistema', user_count: 2, is_system: true, permissions: { classrooms: 'read_write', schedule: 'read_write', admin: 'read_write', buildings: 'read_write' } },
|
{ id: 1, name: 'Administrador', description: 'Acceso total al sistema', user_count: 2, is_system: true, permissions: { classrooms: 'read_write', schedule: 'read_write', admin: 'read_write', buildings: 'read_write' } },
|
||||||
{ id: 2, name: 'Bedel', description: 'Gestión de reservas y aulas', user_count: 5, is_system: false, permissions: { classrooms: 'read_write', schedule: 'read_write', admin: 'read', buildings: 'read' } },
|
{ id: 2, name: 'Bedel', description: 'Gestión de reservas y aulas', user_count: 5, is_system: false, permissions: { classrooms: 'read_write', schedule: 'read_write', admin: 'read', buildings: 'read' } },
|
||||||
{ id: 3, name: 'Docente', description: 'Visualización de horarios', user_count: 18, is_system: false, permissions: { classrooms: 'read', schedule: 'read', admin: 'none', buildings: 'read' } },
|
{ id: 3, name: 'Docente', description: 'Visualización de horarios', user_count: 18, is_system: false, permissions: { classrooms: 'read', schedule: 'read', admin: 'none', buildings: 'read' } },
|
||||||
{ id: 4, name: 'Invitado', description: 'Solo lectura', user_count: 3, is_system: false, permissions: { classrooms: 'read', schedule: 'none', admin: 'none', buildings: 'none' } }
|
{ id: 4, name: 'Invitado', description: 'Solo lectura', user_count: 3, is_system: false, permissions: { classrooms: 'read', schedule: 'none', admin: 'none', buildings: 'none' } }
|
||||||
];
|
];
|
||||||
|
|
||||||
const MOCK_USERS = [
|
const MOCK_USERS = [
|
||||||
@@ -349,7 +349,7 @@ const handleUsersList = async (req, res) => {
|
|||||||
if (role_filter) {
|
if (role_filter) {
|
||||||
filtered = filtered.filter(u => String(u.role_id) === String(role_filter));
|
filtered = filtered.filter(u => String(u.role_id) === String(role_filter));
|
||||||
}
|
}
|
||||||
if (status_filter === 'active') filtered = filtered.filter(u => u.is_active);
|
if (status_filter === 'active') filtered = filtered.filter(u => u.is_active);
|
||||||
if (status_filter === 'inactive') filtered = filtered.filter(u => !u.is_active);
|
if (status_filter === 'inactive') filtered = filtered.filter(u => !u.is_active);
|
||||||
|
|
||||||
res.render('admin/users/list', {
|
res.render('admin/users/list', {
|
||||||
@@ -518,12 +518,12 @@ router.post(['/users/:id/password', '/users/password', '/user_password', '/user_
|
|||||||
// ─── 4. ROLES ─────────────────────────────────────────────────────────────────
|
// ─── 4. ROLES ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
{ id: 'classrooms', name: 'Aulas', icon: 'bi-door-open' },
|
{ id: 'classrooms', name: 'Aulas', icon: 'bi-door-open' },
|
||||||
{ id: 'schedule', name: 'Horarios', icon: 'bi-calendar3' },
|
{ id: 'schedule', name: 'Horarios', icon: 'bi-calendar3' },
|
||||||
{ id: 'buildings', name: 'Edificios', icon: 'bi-buildings' },
|
{ id: 'buildings', name: 'Edificios', icon: 'bi-buildings' },
|
||||||
{ id: 'admin', name: 'Admin', icon: 'bi-shield-lock' },
|
{ id: 'admin', name: 'Admin', icon: 'bi-shield-lock' },
|
||||||
{ id: 'users', name: 'Usuarios', icon: 'bi-people' },
|
{ id: 'users', name: 'Usuarios', icon: 'bi-people' },
|
||||||
{ id: 'reports', name: 'Reportes', icon: 'bi-graph-up' }
|
{ id: 'reports', name: 'Reportes', icon: 'bi-graph-up' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const handleRolesList = async (req, res) => {
|
const handleRolesList = async (req, res) => {
|
||||||
@@ -879,7 +879,7 @@ const handleCommissionsList = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const carRes = await req.apiClient.get('/careers');
|
const carRes = await req.apiClient.get('/careers');
|
||||||
careers = carRes.data?.careers || [];
|
careers = carRes.data?.careers || [];
|
||||||
} catch (carErr) {}
|
} catch (carErr) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si por alguna razón no vinieron academic_terms en commissions, intentar fallback
|
// Si por alguna razón no vinieron academic_terms en commissions, intentar fallback
|
||||||
@@ -887,7 +887,7 @@ const handleCommissionsList = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
const termsRes = await req.apiClient.get('/academic-terms');
|
const termsRes = await req.apiClient.get('/academic-terms');
|
||||||
academic_terms = termsRes.data?.terms || termsRes.data?.academic_terms || [];
|
academic_terms = termsRes.data?.terms || termsRes.data?.academic_terms || [];
|
||||||
} catch (tErr) {}
|
} catch (tErr) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uRes.status === 'fulfilled' && uRes.value.data) {
|
if (uRes.status === 'fulfilled' && uRes.value.data) {
|
||||||
|
|||||||
+281
-203
@@ -8,9 +8,11 @@
|
|||||||
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-2">
|
<div class="d-flex flex-wrap justify-content-between align-items-center mb-4 gap-2">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="h3 mb-1">
|
<h1 class="h3 mb-1">
|
||||||
<i class="bi bi-file-earmark-spreadsheet text-success me-2"></i>Google Sheets Academic Sync & Gestión de Datos
|
<i class="bi bi-file-earmark-spreadsheet text-success me-2"></i>Google Sheets Academic Sync & Gestión de
|
||||||
|
Datos
|
||||||
</h1>
|
</h1>
|
||||||
<p class="text-muted small mb-0">Extrae, normaliza y sincroniza carreras, aulas, comisiones y cronogramas de cursada desde Google Sheets con soporte de configuración dinámica y reinicio de entorno.</p>
|
<p class="text-muted small mb-0">Extrae, normaliza y sincroniza carreras, aulas, comisiones y cronogramas de
|
||||||
|
cursada desde Google Sheets con soporte de configuración dinámica y reinicio de entorno.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex gap-2">
|
<div class="d-flex gap-2">
|
||||||
<a href="/schedule/calendar_view" class="btn btn-outline-primary btn-sm">
|
<a href="/schedule/calendar_view" class="btn btn-outline-primary btn-sm">
|
||||||
@@ -24,33 +26,33 @@
|
|||||||
|
|
||||||
<!-- Feedback Alerts -->
|
<!-- Feedback Alerts -->
|
||||||
{% if flash_msg %}
|
{% if flash_msg %}
|
||||||
<div class="alert alert-{{ flash_type }} alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
|
<div class="alert alert-{{ flash_type }} alert-dismissible fade show border-0 shadow-sm mb-4" role="alert">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
{% if flash_type == 'success' %}
|
{% if flash_type == 'success' %}
|
||||||
<i class="bi bi-check-circle-fill fs-5 me-2 text-success"></i>
|
<i class="bi bi-check-circle-fill fs-5 me-2 text-success"></i>
|
||||||
{% elif flash_type == 'danger' %}
|
{% elif flash_type == 'danger' %}
|
||||||
<i class="bi bi-exclamation-triangle-fill fs-5 me-2 text-danger"></i>
|
<i class="bi bi-exclamation-triangle-fill fs-5 me-2 text-danger"></i>
|
||||||
{% elif flash_type == 'warning' %}
|
{% elif flash_type == 'warning' %}
|
||||||
<i class="bi bi-exclamation-circle-fill fs-5 me-2 text-warning"></i>
|
<i class="bi bi-exclamation-circle-fill fs-5 me-2 text-warning"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-info-circle-fill fs-5 me-2 text-info"></i>
|
<i class="bi bi-info-circle-fill fs-5 me-2 text-info"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div>{{ flash_msg }}</div>
|
<div>{{ flash_msg }}</div>
|
||||||
</div>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if sync_error %}
|
{% if sync_error %}
|
||||||
<div class="alert alert-danger border-0 shadow-sm mb-4" role="alert">
|
<div class="alert alert-danger border-0 shadow-sm mb-4" role="alert">
|
||||||
<div class="d-flex align-items-start">
|
<div class="d-flex align-items-start">
|
||||||
<i class="bi bi-x-octagon-fill fs-4 me-3 text-danger flex-shrink-0"></i>
|
<i class="bi bi-x-octagon-fill fs-4 me-3 text-danger flex-shrink-0"></i>
|
||||||
<div>
|
<div>
|
||||||
<h6 class="alert-heading fw-bold mb-1">Error durante la sincronización:</h6>
|
<h6 class="alert-heading fw-bold mb-1">Error durante la sincronización:</h6>
|
||||||
<p class="small mb-0">{{ sync_error }}</p>
|
<p class="small mb-0">{{ sync_error }}</p>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Metrics Cards -->
|
<!-- Metrics Cards -->
|
||||||
@@ -98,8 +100,10 @@
|
|||||||
<h5 class="card-title h6 mb-0 fw-bold">
|
<h5 class="card-title h6 mb-0 fw-bold">
|
||||||
<i class="bi bi-gear-wide-connected text-primary me-2"></i>Configuración Global del Google Sheet
|
<i class="bi bi-gear-wide-connected text-primary me-2"></i>Configuración Global del Google Sheet
|
||||||
</h5>
|
</h5>
|
||||||
<span class="badge {% if sheets_config.source == 'database' %}bg-success-subtle text-success border border-success-subtle{% else %}bg-secondary-subtle text-secondary border{% endif %}">
|
<span
|
||||||
Origen: {{ 'Base de Datos (Personalizado)' if sheets_config.source == 'database' else ('Variables de Entorno' if sheets_config.source == 'environment' else 'Predeterminado') }}
|
class="badge {% if sheets_config.source == 'database' %}bg-success-subtle text-success border border-success-subtle{% else %}bg-secondary-subtle text-secondary border{% endif %}">
|
||||||
|
Origen: {{ 'Base de Datos (Personalizado)' if sheets_config.source == 'database' else ('Variables de
|
||||||
|
Entorno' if sheets_config.source == 'environment' else 'Predeterminado') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
@@ -110,23 +114,26 @@
|
|||||||
</label>
|
</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-text bg-body-secondary"><i class="bi bi-link-45deg"></i></span>
|
<span class="input-group-text bg-body-secondary"><i class="bi bi-link-45deg"></i></span>
|
||||||
<input type="text" class="form-control font-monospace small" id="google_sheets_url" name="google_sheets_url"
|
<input type="text" class="form-control font-monospace small" id="google_sheets_url"
|
||||||
value="{{ sheets_config.active_url }}" required
|
name="google_sheets_url" value="{{ sheets_config.active_url }}" required
|
||||||
placeholder="https://docs.google.com/spreadsheets/d/.../pub?output=csv o enlace compartido">
|
placeholder="https://docs.google.com/spreadsheets/d/.../pub?output=csv o enlace compartido">
|
||||||
<button type="submit" class="btn btn-primary px-3">
|
<button type="submit" class="btn btn-primary px-3">
|
||||||
<i class="bi bi-floppy me-1"></i>Guardar Enlace
|
<i class="bi bi-floppy me-1"></i>Guardar Enlace
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-text mt-2">
|
<div class="form-text mt-2">
|
||||||
<i class="bi bi-info-circle me-1"></i>
|
<i class="bi bi-info-circle me-1"></i>
|
||||||
Acepta enlaces web publicados (<code>/pub?output=csv</code>) o enlaces estándar de Google Sheets (<code>/spreadsheets/d/ID/edit</code>). El sistema los normaliza automáticamente para consultar cada pestaña de día (Lunes a Sábado).
|
Acepta enlaces web publicados (<code>/pub?output=csv</code>) o enlaces estándar de Google Sheets
|
||||||
|
(<code>/spreadsheets/d/ID/edit</code>). El sistema los normaliza automáticamente para consultar
|
||||||
|
cada pestaña de día (Lunes a Sábado).
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-between align-items-center">
|
<div class="d-flex justify-content-between align-items-center">
|
||||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="restoreDefaultUrl()">
|
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="restoreDefaultUrl()">
|
||||||
<i class="bi bi-arrow-counterclockwise me-1"></i>Restaurar URL Oficial UniCABA
|
<i class="bi bi-arrow-counterclockwise me-1"></i>Restaurar URL Oficial UniCABA
|
||||||
</button>
|
</button>
|
||||||
<a href="{{ sheets_config.active_url }}" target="_blank" rel="noopener noreferrer" class="small text-decoration-none">
|
<a href="{{ sheets_config.active_url }}" target="_blank" rel="noopener noreferrer"
|
||||||
|
class="small text-decoration-none">
|
||||||
<i class="bi bi-box-arrow-up-right me-1"></i>Abrir Enlace Actual en Google Docs
|
<i class="bi bi-box-arrow-up-right me-1"></i>Abrir Enlace Actual en Google Docs
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -140,27 +147,32 @@
|
|||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-lg-8 mb-3 mb-lg-0">
|
<div class="col-lg-8 mb-3 mb-lg-0">
|
||||||
<div class="d-flex align-items-center mb-2">
|
<div class="d-flex align-items-center mb-2">
|
||||||
<span class="badge bg-success-subtle text-success border border-success-subtle px-3 py-1 me-2 fw-semibold">
|
<span
|
||||||
|
class="badge bg-success-subtle text-success border border-success-subtle px-3 py-1 me-2 fw-semibold">
|
||||||
<i class="bi bi-cloud-check me-1"></i>Sincronización Bidireccional
|
<i class="bi bi-cloud-check me-1"></i>Sincronización Bidireccional
|
||||||
</span>
|
</span>
|
||||||
<span class="badge bg-light text-muted border">UniCABA 2026</span>
|
<span class="badge bg-light text-muted border">UniCABA 2026</span>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="h5 mb-2 fw-bold">Cartelera Académica Oficial (Lunes a Sábado)</h4>
|
<h4 class="h5 mb-2 fw-bold">Cartelera Académica Oficial (Lunes a Sábado)</h4>
|
||||||
<p class="text-muted small mb-2">
|
<p class="text-muted small mb-2">
|
||||||
Descarga las 6 hojas de cálculo semanales, creando o actualizando en lote las Carreras, Aulas (físicas y virtuales), Códigos de Materia, Comisiones de Cursada y las Clases semanales en el calendario sin duplicar registros.
|
Descarga las 6 hojas de cálculo semanales, creando o actualizando en lote las Carreras, Aulas
|
||||||
|
(físicas y virtuales), Códigos de Materia, Comisiones de Cursada y las Clases semanales en el
|
||||||
|
calendario sin duplicar registros.
|
||||||
</p>
|
</p>
|
||||||
<div class="d-flex flex-wrap gap-1">
|
<div class="d-flex flex-wrap gap-1">
|
||||||
{% for s in metrics.sheets %}
|
{% for s in metrics.sheets %}
|
||||||
<span class="badge bg-body-tertiary text-secondary border small">
|
<span class="badge bg-body-tertiary text-secondary border small">
|
||||||
<i class="bi bi-calendar-event me-1 text-primary"></i>{{ s.name }}
|
<i class="bi bi-calendar-event me-1 text-primary"></i>{{ s.name }}
|
||||||
</span>
|
</span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 text-lg-end">
|
<div class="col-lg-4 text-lg-end">
|
||||||
<form method="POST" id="syncForm" action="/admin/google_sheets_import" onsubmit="startSync()">
|
<form method="POST" id="syncForm" action="/admin/google_sheets_import" onsubmit="startSync()">
|
||||||
<input type="hidden" name="sheets_url" id="syncSheetsUrl" value="{{ sheets_config.active_url }}">
|
<input type="hidden" name="sheets_url" id="syncSheetsUrl"
|
||||||
<button type="submit" id="syncBtn" class="btn btn-success btn-lg px-4 py-2 shadow-sm fw-semibold">
|
value="{{ sheets_config.active_url }}">
|
||||||
|
<button type="submit" id="syncBtn"
|
||||||
|
class="btn btn-success btn-lg px-4 py-2 shadow-sm fw-semibold">
|
||||||
<i class="bi bi-arrow-repeat me-2"></i>Sincronizar Datos Ahora
|
<i class="bi bi-arrow-repeat me-2"></i>Sincronizar Datos Ahora
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -176,7 +188,8 @@
|
|||||||
<!-- Sync Results (if just completed) -->
|
<!-- Sync Results (if just completed) -->
|
||||||
{% if stats %}
|
{% if stats %}
|
||||||
<div class="card border-0 shadow-sm mb-4 border-start border-success border-4">
|
<div class="card border-0 shadow-sm mb-4 border-start border-success border-4">
|
||||||
<div class="card-header bg-success bg-opacity-10 text-success py-3 d-flex justify-content-between align-items-center">
|
<div
|
||||||
|
class="card-header bg-success bg-opacity-10 text-success py-3 d-flex justify-content-between align-items-center">
|
||||||
<h5 class="card-title h6 mb-0 fw-bold">
|
<h5 class="card-title h6 mb-0 fw-bold">
|
||||||
<i class="bi bi-check-circle-fill me-2"></i>Informe Detallado de Sincronización
|
<i class="bi bi-check-circle-fill me-2"></i>Informe Detallado de Sincronización
|
||||||
</h5>
|
</h5>
|
||||||
@@ -225,7 +238,8 @@
|
|||||||
{% if stats.by_day %}
|
{% if stats.by_day %}
|
||||||
<div class="card bg-body-tertiary border mb-3">
|
<div class="card bg-body-tertiary border mb-3">
|
||||||
<div class="card-header bg-transparent py-2 border-bottom">
|
<div class="card-header bg-transparent py-2 border-bottom">
|
||||||
<h6 class="mb-0 small fw-bold text-dark"><i class="bi bi-calendar3 me-2 text-primary"></i>Desglose Semanal por Día de Cursada:</h6>
|
<h6 class="mb-0 small fw-bold text-dark"><i class="bi bi-calendar3 me-2 text-primary"></i>Desglose
|
||||||
|
Semanal por Día de Cursada:</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-2">
|
<div class="card-body p-2">
|
||||||
<div class="row g-2 text-center">
|
<div class="row g-2 text-center">
|
||||||
@@ -233,7 +247,8 @@
|
|||||||
<div class="col-md-2 col-4">
|
<div class="col-md-2 col-4">
|
||||||
<div class="p-2 border rounded bg-white shadow-sm">
|
<div class="p-2 border rounded bg-white shadow-sm">
|
||||||
<span class="fw-bold d-block text-secondary small">{{ day_name }}</span>
|
<span class="fw-bold d-block text-secondary small">{{ day_name }}</span>
|
||||||
<span class="badge {% if d_info.status == 'OK' %}bg-success-subtle text-success border border-success-subtle{% else %}bg-danger-subtle text-danger border border-danger-subtle{% endif %}">
|
<span
|
||||||
|
class="badge {% if d_info.status == 'OK' %}bg-success-subtle text-success border border-success-subtle{% else %}bg-danger-subtle text-danger border border-danger-subtle{% endif %}">
|
||||||
{{ d_info.rows_count }} filas
|
{{ d_info.rows_count }} filas
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -245,14 +260,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if stats.errors and (stats.errors|length > 0) %}
|
{% if stats.errors and (stats.errors|length > 0) %}
|
||||||
<div class="alert alert-warning mb-0 small">
|
<div class="alert alert-warning mb-0 small">
|
||||||
<h6 class="alert-heading fw-bold mb-1"><i class="bi bi-exclamation-triangle me-1"></i>Advertencias o incidencias detectadas:</h6>
|
<h6 class="alert-heading fw-bold mb-1"><i class="bi bi-exclamation-triangle me-1"></i>Advertencias o
|
||||||
<ul class="mb-0 ps-3">
|
incidencias detectadas:</h6>
|
||||||
{% for err in stats.errors %}
|
<ul class="mb-0 ps-3">
|
||||||
<li>{{ err }}</li>
|
{% for err in stats.errors %}
|
||||||
{% endfor %}
|
<li>{{ err }}</li>
|
||||||
</ul>
|
{% endfor %}
|
||||||
</div>
|
</ul>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -260,74 +276,91 @@
|
|||||||
|
|
||||||
<!-- Academic Data Purge / Reset Tool (Zona de Mantenimiento) -->
|
<!-- Academic Data Purge / Reset Tool (Zona de Mantenimiento) -->
|
||||||
<div class="card border-0 shadow-sm mb-4 border-start border-danger border-4">
|
<div class="card border-0 shadow-sm mb-4 border-start border-danger border-4">
|
||||||
<div class="card-header bg-danger bg-opacity-10 text-danger py-3 d-flex justify-content-between align-items-center">
|
<div
|
||||||
|
class="card-header bg-danger bg-opacity-10 text-danger py-3 d-flex justify-content-between align-items-center">
|
||||||
<div>
|
<div>
|
||||||
<h5 class="card-title h6 mb-0 fw-bold">
|
<h5 class="card-title h6 mb-0 fw-bold">
|
||||||
<i class="bi bi-trash3 text-danger me-2"></i>Herramienta de Reinicio y Purga Académica (Testing & Reset)
|
<i class="bi bi-trash3 text-danger me-2"></i>Herramienta de Reinicio y Purga Académica (Testing &
|
||||||
|
Reset)
|
||||||
</h5>
|
</h5>
|
||||||
<small class="text-muted">Permite eliminar de forma limpia carreras, aulas y asignaciones para realizar pruebas completas del importador desde cero.</small>
|
<small class="text-muted">Permite eliminar de forma limpia carreras, aulas y asignaciones para realizar
|
||||||
|
pruebas completas del importador desde cero.</small>
|
||||||
</div>
|
</div>
|
||||||
<span class="badge bg-danger text-white">Zona de Peligro</span>
|
<span class="badge bg-danger text-white">Zona de Peligro</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<p class="small text-muted mb-3">
|
<p class="small text-muted mb-3">
|
||||||
Seleccione las entidades que desea eliminar de la base de datos antes de re-importar. Las restricciones de clave foránea se limpian automáticamente en el orden estricto.
|
Seleccione las entidades que desea eliminar de la base de datos antes de re-importar. Las restricciones
|
||||||
<strong class="text-body">Nota de seguridad:</strong> Los usuarios del sistema, credenciales de acceso, roles RBAC y registros de auditoría <u>NUNCA</u> se eliminan.
|
de clave foránea se limpian automáticamente en el orden estricto.
|
||||||
|
<strong class="text-body">Nota de seguridad:</strong> Los usuarios del sistema, credenciales de acceso,
|
||||||
|
roles RBAC y registros de auditoría <u>NUNCA</u> se eliminan.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<form id="purgeForm" method="POST" action="/admin/reset_academic_data">
|
<form id="purgeForm" method="POST" action="/admin/reset_academic_data">
|
||||||
<div class="row g-3 mb-3">
|
<div class="row g-3 mb-3">
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded bg-body-tertiary">
|
<div class="form-check p-2 border rounded bg-body-tertiary">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_reservations" id="chk_reservations" value="true" checked>
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_reservations"
|
||||||
|
id="chk_reservations" value="true" checked>
|
||||||
<label class="form-check-label fw-semibold" for="chk_reservations">
|
<label class="form-check-label fw-semibold" for="chk_reservations">
|
||||||
Asignaciones de Aulas (Reservas)
|
Asignaciones de Aulas (Reservas)
|
||||||
<small class="d-block text-muted fw-normal">Elimina las clases cargadas en el calendario.</small>
|
<small class="d-block text-muted fw-normal">Elimina las clases cargadas en el
|
||||||
|
calendario.</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded bg-body-tertiary">
|
<div class="form-check p-2 border rounded bg-body-tertiary">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_classrooms" id="chk_classrooms" value="true">
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_classrooms"
|
||||||
|
id="chk_classrooms" value="true">
|
||||||
<label class="form-check-label fw-semibold" for="chk_classrooms">
|
<label class="form-check-label fw-semibold" for="chk_classrooms">
|
||||||
Aulas Físicas y Virtuales
|
Aulas Físicas y Virtuales
|
||||||
<small class="d-block text-muted fw-normal">Elimina aulas y espacios áulicos creados.</small>
|
<small class="d-block text-muted fw-normal">Elimina aulas y espacios áulicos
|
||||||
|
creados.</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded bg-body-tertiary">
|
<div class="form-check p-2 border rounded bg-body-tertiary">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_commissions" id="chk_commissions" value="true">
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_commissions"
|
||||||
|
id="chk_commissions" value="true">
|
||||||
<label class="form-check-label fw-semibold" for="chk_commissions">
|
<label class="form-check-label fw-semibold" for="chk_commissions">
|
||||||
Comisiones de Cursada
|
Comisiones de Cursada
|
||||||
<small class="d-block text-muted fw-normal">Elimina turnos y comisiones de asignaturas.</small>
|
<small class="d-block text-muted fw-normal">Elimina turnos y comisiones de
|
||||||
|
asignaturas.</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded bg-body-tertiary">
|
<div class="form-check p-2 border rounded bg-body-tertiary">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_subjects" id="chk_subjects" value="true">
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_subjects"
|
||||||
|
id="chk_subjects" value="true">
|
||||||
<label class="form-check-label fw-semibold" for="chk_subjects">
|
<label class="form-check-label fw-semibold" for="chk_subjects">
|
||||||
Asignaturas / Materias
|
Asignaturas / Materias
|
||||||
<small class="d-block text-muted fw-normal">Elimina el catálogo de materias importadas.</small>
|
<small class="d-block text-muted fw-normal">Elimina el catálogo de materias
|
||||||
|
importadas.</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded bg-body-tertiary">
|
<div class="form-check p-2 border rounded bg-body-tertiary">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_careers" id="chk_careers" value="true">
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_careers"
|
||||||
|
id="chk_careers" value="true">
|
||||||
<label class="form-check-label fw-semibold" for="chk_careers">
|
<label class="form-check-label fw-semibold" for="chk_careers">
|
||||||
Carreras Académicas
|
Carreras Académicas
|
||||||
<small class="d-block text-muted fw-normal">Elimina las carreras (Tecnicaturas, Licenciaturas, etc).</small>
|
<small class="d-block text-muted fw-normal">Elimina las carreras (Tecnicaturas,
|
||||||
|
Licenciaturas, etc).</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-lg-4">
|
<div class="col-md-6 col-lg-4">
|
||||||
<div class="form-check p-2 border rounded border-danger bg-danger bg-opacity-10">
|
<div class="form-check p-2 border rounded border-danger bg-danger bg-opacity-10">
|
||||||
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_all" id="chk_all" value="true" onchange="toggleSelectAll(this.checked)">
|
<input class="form-check-input ms-1 me-2" type="checkbox" name="reset_all" id="chk_all"
|
||||||
|
value="true" onchange="toggleSelectAll(this.checked)">
|
||||||
<label class="form-check-label fw-bold text-danger" for="chk_all">
|
<label class="form-check-label fw-bold text-danger" for="chk_all">
|
||||||
Reiniciar Todo el Esquema
|
Reiniciar Todo el Esquema
|
||||||
<small class="d-block text-danger fw-normal">Marca automáticamente todas las entidades.</small>
|
<small class="d-block text-danger fw-normal">Marca automáticamente todas las
|
||||||
|
entidades.</small>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -376,21 +409,23 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="badge bg-primary-subtle text-primary border border-primary-subtle small">
|
<span class="badge bg-primary-subtle text-primary border border-primary-subtle small">
|
||||||
{{ s.career_obj.name if s.career_obj else (s.career_name or s.department or 'General') }}
|
{{ s.career_obj.name if s.career_obj else (s.career_name or s.department or 'General')
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="small text-muted">
|
<span class="small text-muted">
|
||||||
{{ s.commissions_count if s.commissions_count is defined else (s.commissions|length if s.commissions else 0) }} comisión(es)
|
{{ s.commissions_count if s.commissions_count is defined else (s.commissions|length if
|
||||||
|
s.commissions else 0) }} comisión(es)
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if s.is_active %}
|
{% if s.is_active %}
|
||||||
<span class="badge bg-success-subtle text-success border border-success-subtle small">
|
<span class="badge bg-success-subtle text-success border border-success-subtle small">
|
||||||
<i class="bi bi-check-circle me-1"></i>Activa
|
<i class="bi bi-check-circle me-1"></i>Activa
|
||||||
</span>
|
</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge bg-secondary small">Inactiva</span>
|
<span class="badge bg-secondary small">Inactiva</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -398,7 +433,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="text-center py-5 text-muted">
|
<td colspan="5" class="text-center py-5 text-muted">
|
||||||
<i class="bi bi-cloud-arrow-down fs-1 d-block mb-2 text-secondary"></i>
|
<i class="bi bi-cloud-arrow-down fs-1 d-block mb-2 text-secondary"></i>
|
||||||
No hay materias en la base de datos actualmente. Haga clic en "Sincronizar Datos Ahora" para importar.
|
No hay materias en la base de datos actualmente. Haga clic en "Sincronizar Datos Ahora" para
|
||||||
|
importar.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -408,137 +444,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal de Confirmación de Purga de Datos -->
|
|
||||||
<div class="modal fade" id="purgeConfirmModal" tabindex="-1" aria-labelledby="purgeModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
|
||||||
<div class="modal-content border-0 shadow">
|
|
||||||
<div class="modal-header bg-danger text-white">
|
|
||||||
<h5 class="modal-title h6 mb-0" id="purgeModalLabel">
|
|
||||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>Confirmar Eliminación de Datos Académicos
|
|
||||||
</h5>
|
|
||||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body p-4">
|
|
||||||
<div class="text-center mb-3">
|
|
||||||
<i class="bi bi-trash3 text-danger display-4"></i>
|
|
||||||
</div>
|
|
||||||
<p class="mb-2 text-center fw-semibold">
|
|
||||||
¿Está seguro de que desea eliminar los datos académicos seleccionados?
|
|
||||||
</p>
|
|
||||||
<p class="small text-muted text-center mb-3">
|
|
||||||
Esta acción eliminará las asignaciones de aulas, comisiones, asignaturas, carreras o aulas marcadas para permitir probar el importador limpio. Los usuarios del sistema y roles no se eliminarán.
|
|
||||||
</p>
|
|
||||||
<div class="alert alert-warning small mb-0">
|
|
||||||
<i class="bi bi-shield-exclamation me-1"></i>
|
|
||||||
Para confirmar, haga clic en el botón rojo a continuación.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer bg-body-tertiary">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
|
|
||||||
<button type="button" class="btn btn-danger fw-semibold" onclick="confirmPurge()">
|
|
||||||
<i class="bi bi-trash3 me-1"></i>Sí, Eliminar Datos
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block extra_js %}
|
|
||||||
<script>
|
|
||||||
function startSync() {
|
|
||||||
const btn = document.getElementById('syncBtn');
|
|
||||||
const spinner = document.getElementById('syncSpinner');
|
|
||||||
const urlInput = document.getElementById('google_sheets_url');
|
|
||||||
const syncUrlInput = document.getElementById('syncSheetsUrl');
|
|
||||||
|
|
||||||
if (urlInput && syncUrlInput) {
|
|
||||||
syncUrlInput.value = urlInput.value.trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (btn) {
|
|
||||||
btn.disabled = true;
|
|
||||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status"></span>Sincronizando...';
|
|
||||||
}
|
|
||||||
if (spinner) {
|
|
||||||
spinner.classList.remove('d-none');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function restoreDefaultUrl() {
|
|
||||||
const defaultUrl = "{{ sheets_config.default_url }}";
|
|
||||||
const input = document.getElementById('google_sheets_url');
|
|
||||||
if (input && defaultUrl) {
|
|
||||||
input.value = defaultUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleSelectAll(checked) {
|
|
||||||
document.getElementById('chk_reservations').checked = checked;
|
|
||||||
document.getElementById('chk_classrooms').checked = checked;
|
|
||||||
document.getElementById('chk_commissions').checked = checked;
|
|
||||||
document.getElementById('chk_subjects').checked = checked;
|
|
||||||
document.getElementById('chk_careers').checked = checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openPurgeModal() {
|
|
||||||
const isAll = document.getElementById('chk_all').checked;
|
|
||||||
const isRes = isAll || document.getElementById('chk_reservations').checked;
|
|
||||||
const isCls = isAll || document.getElementById('chk_classrooms').checked;
|
|
||||||
const isCom = isAll || document.getElementById('chk_commissions').checked;
|
|
||||||
const isSub = isAll || document.getElementById('chk_subjects').checked;
|
|
||||||
const isCar = isAll || document.getElementById('chk_careers').checked;
|
|
||||||
|
|
||||||
const anyChecked = isRes || isCls || isCom || isSub || isCar;
|
|
||||||
if (!anyChecked) {
|
|
||||||
alert('Por favor seleccione al menos una entidad para purgar.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const listEl = document.getElementById('purgeEntitiesList');
|
|
||||||
if (listEl) {
|
|
||||||
listEl.innerHTML = '';
|
|
||||||
if (isAll) {
|
|
||||||
listEl.innerHTML += '<li class="list-group-item list-group-item-danger fw-bold"><i class="bi bi-trash-fill me-2"></i>REINICIO TOTAL DEL ESQUEMA (Carreras, Asignaturas, Comisiones, Aulas y Reservas)</li>';
|
|
||||||
} else {
|
|
||||||
if (isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-mortarboard me-2"></i>Carreras Académicas y sus Asignaturas asociadas</li>';
|
|
||||||
if (isSub && !isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-book me-2"></i>Asignaturas / Materias y sus Comisiones</li>';
|
|
||||||
if (isCom && !isSub && !isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-diagram-3 me-2"></i>Comisiones de Cursada e Inscripciones</li>';
|
|
||||||
if (isRes) listEl.innerHTML += '<li class="list-group-item text-danger"><i class="bi bi-calendar-event me-2"></i>Asignaciones de Aulas (Reservas del Calendario)</li>';
|
|
||||||
if (isCls) listEl.innerHTML += '<li class="list-group-item text-danger"><i class="bi bi-door-open me-2"></i>Aulas Físicas y Virtuales</li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const modalEl = document.getElementById('purgeConfirmModal');
|
|
||||||
if (modalEl && typeof bootstrap !== 'undefined' && bootstrap.Modal) {
|
|
||||||
try {
|
|
||||||
const modal = new bootstrap.Modal(modalEl);
|
|
||||||
modal.show();
|
|
||||||
return;
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Bootstrap modal error, falling back to window.confirm:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback nativo si Bootstrap modal no estuviera disponible
|
|
||||||
if (confirm("ATENCIÓN: ¿Confirma la purga y eliminación permanente de los datos académicos seleccionados?\nEsta acción es irreversible.")) {
|
|
||||||
confirmPurge();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function confirmPurge() {
|
|
||||||
const btn = document.getElementById('btnDoPurge');
|
|
||||||
if (btn) {
|
|
||||||
btn.disabled = true;
|
|
||||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Purgando base de datos...';
|
|
||||||
}
|
|
||||||
const form = document.getElementById('purgeForm');
|
|
||||||
if (form) {
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<!-- Modal: Confirmación de Purga de Datos Académicos -->
|
<!-- Modal: Confirmación de Purga de Datos Académicos -->
|
||||||
<div class="modal fade" id="purgeConfirmModal" tabindex="-1" aria-labelledby="purgeConfirmModalLabel" aria-hidden="true">
|
<div class="modal fade" id="purgeConfirmModal" tabindex="-1" aria-labelledby="purgeConfirmModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
@@ -573,3 +478,176 @@ function confirmPurge() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_js %}
|
||||||
|
<script>
|
||||||
|
function startSync() {
|
||||||
|
const btn = document.getElementById('syncBtn');
|
||||||
|
const spinner = document.getElementById('syncSpinner');
|
||||||
|
const urlInput = document.getElementById('google_sheets_url');
|
||||||
|
const syncUrlInput = document.getElementById('syncSheetsUrl');
|
||||||
|
|
||||||
|
if (urlInput && syncUrlInput) {
|
||||||
|
syncUrlInput.value = urlInput.value.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status"></span>Sincronizando con Google Sheets...';
|
||||||
|
}
|
||||||
|
if (spinner) {
|
||||||
|
spinner.classList.remove('d-none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearFilters() {
|
||||||
|
const d = document.getElementById('filter_day');
|
||||||
|
if (d) d.value = '';
|
||||||
|
const c = document.getElementById('filter_career');
|
||||||
|
if (c) c.value = '';
|
||||||
|
const s = document.getElementById('filter_subject');
|
||||||
|
if (s) s.value = '';
|
||||||
|
const m = document.getElementById('manual_date');
|
||||||
|
if (m) m.value = '';
|
||||||
|
const single = document.getElementById('single_date_only');
|
||||||
|
if (single) single.checked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function inspectOnlineSheets() {
|
||||||
|
const btn = document.getElementById('btnInspectSheet');
|
||||||
|
const btnText = document.getElementById('inspectBtnText');
|
||||||
|
const alertBox = document.getElementById('inspectAlert');
|
||||||
|
const alertMsg = document.getElementById('inspectAlertMsg');
|
||||||
|
const urlInput = document.getElementById('google_sheets_url');
|
||||||
|
|
||||||
|
if (btn) btn.disabled = true;
|
||||||
|
if (btnText) btnText.innerText = 'Inspeccionando...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
sheets_url: urlInput ? urlInput.value.trim() : ''
|
||||||
|
};
|
||||||
|
const resp = await fetch('/admin/sheets_inspect', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(payload)
|
||||||
|
});
|
||||||
|
const data = await resp.json();
|
||||||
|
|
||||||
|
if (data.status === 'success' && data.metadata) {
|
||||||
|
const meta = data.metadata;
|
||||||
|
// Poblar datalists dinámicamente con carreras del Sheet online
|
||||||
|
const careersList = document.getElementById('careersDataList');
|
||||||
|
if (careersList && meta.careers) {
|
||||||
|
careersList.innerHTML = '';
|
||||||
|
meta.careers.forEach(function(c) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = c;
|
||||||
|
careersList.appendChild(opt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Poblar datalists dinámicamente con materias del Sheet online
|
||||||
|
const subjectsList = document.getElementById('subjectsDataList');
|
||||||
|
if (subjectsList && meta.subjects) {
|
||||||
|
subjectsList.innerHTML = '';
|
||||||
|
meta.subjects.forEach(function(s) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = s.code + ' - ' + s.name;
|
||||||
|
subjectsList.appendChild(opt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alertBox && alertMsg) {
|
||||||
|
alertBox.className = 'alert alert-success border-0 shadow-sm mb-4';
|
||||||
|
alertMsg.innerHTML = '<strong>Inspección completada con éxito:</strong> Se detectaron <strong>' + (meta.total_rows || 0) + ' filas</strong>, <strong>' + (meta.careers ? meta.careers.length : 0) + ' carreras</strong> y <strong>' + (meta.subjects ? meta.subjects.length : 0) + ' materias</strong> disponibles en el Sheet online. Las sugerencias se han cargado en los campos de filtro.';
|
||||||
|
alertBox.classList.remove('d-none');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error(data.message || 'No se pudieron extraer datos del Sheet online.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (alertBox && alertMsg) {
|
||||||
|
alertBox.className = 'alert alert-danger border-0 shadow-sm mb-4';
|
||||||
|
alertMsg.innerHTML = '<strong>Error al inspeccionar Sheet online:</strong> ' + err.message;
|
||||||
|
alertBox.classList.remove('d-none');
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (btn) btn.disabled = false;
|
||||||
|
if (btnText) btnText.innerText = 'Inspeccionar Sheet Online';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreDefaultUrl() {
|
||||||
|
const defaultUrl = "{{ sheets_config.default_url }}";
|
||||||
|
const input = document.getElementById('google_sheets_url');
|
||||||
|
if (input && defaultUrl) {
|
||||||
|
input.value = defaultUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSelectAll(checked) {
|
||||||
|
document.getElementById('chk_reservations').checked = checked;
|
||||||
|
document.getElementById('chk_classrooms').checked = checked;
|
||||||
|
document.getElementById('chk_commissions').checked = checked;
|
||||||
|
document.getElementById('chk_subjects').checked = checked;
|
||||||
|
document.getElementById('chk_careers').checked = checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openPurgeModal() {
|
||||||
|
const isAll = document.getElementById('chk_all').checked;
|
||||||
|
const isRes = isAll || document.getElementById('chk_reservations').checked;
|
||||||
|
const isCls = isAll || document.getElementById('chk_classrooms').checked;
|
||||||
|
const isCom = isAll || document.getElementById('chk_commissions').checked;
|
||||||
|
const isSub = isAll || document.getElementById('chk_subjects').checked;
|
||||||
|
const isCar = isAll || document.getElementById('chk_careers').checked;
|
||||||
|
|
||||||
|
const anyChecked = isRes || isCls || isCom || isSub || isCar;
|
||||||
|
if (!anyChecked) {
|
||||||
|
alert('Por favor seleccione al menos una entidad para purgar.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const listEl = document.getElementById('purgeEntitiesList');
|
||||||
|
if (listEl) {
|
||||||
|
listEl.innerHTML = '';
|
||||||
|
if (isAll) {
|
||||||
|
listEl.innerHTML += '<li class="list-group-item list-group-item-danger fw-bold"><i class="bi bi-trash-fill me-2"></i>REINICIO TOTAL DEL ESQUEMA (Carreras, Asignaturas, Comisiones, Aulas y Reservas)</li>';
|
||||||
|
} else {
|
||||||
|
if (isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-mortarboard me-2"></i>Carreras Académicas y sus Asignaturas asociadas</li>';
|
||||||
|
if (isSub && !isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-book me-2"></i>Asignaturas / Materias y sus Comisiones</li>';
|
||||||
|
if (isCom && !isSub && !isCar) listEl.innerHTML += '<li class="list-group-item text-danger fw-semibold"><i class="bi bi-diagram-3 me-2"></i>Comisiones de Cursada e Inscripciones</li>';
|
||||||
|
if (isRes) listEl.innerHTML += '<li class="list-group-item text-danger"><i class="bi bi-calendar-event me-2"></i>Asignaciones de Aulas (Reservas del Calendario)</li>';
|
||||||
|
if (isCls) listEl.innerHTML += '<li class="list-group-item text-danger"><i class="bi bi-door-open me-2"></i>Aulas Físicas y Virtuales</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const modalEl = document.getElementById('purgeConfirmModal');
|
||||||
|
if (modalEl && typeof bootstrap !== 'undefined' && bootstrap.Modal) {
|
||||||
|
try {
|
||||||
|
const modal = new bootstrap.Modal(modalEl);
|
||||||
|
modal.show();
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Bootstrap modal error, falling back to window.confirm:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (confirm("ATENCIÓN: ¿Confirma la purga y eliminación permanente de los datos académicos seleccionados?\nEsta acción es irreversible.")) {
|
||||||
|
confirmPurge();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmPurge() {
|
||||||
|
const btn = document.getElementById('btnDoPurge');
|
||||||
|
if (btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Purgando base de datos...';
|
||||||
|
}
|
||||||
|
const form = document.getElementById('purgeForm');
|
||||||
|
if (form) {
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user