fix: update bedelia views for today and weekly reservations, available rooms and unassigned commissions

This commit is contained in:
2026-10-07 19:16:35 -03:00
parent 5764203232
commit ff6480f591
9 changed files with 449 additions and 23 deletions
+28 -1
View File
@@ -213,6 +213,8 @@ def get_commissions():
elif active == 'false': elif active == 'false':
query = query.filter(Commission.active == False) query = query.filter(Commission.active == False)
unassigned_room = request.args.get('unassigned_room', '').strip().lower()
commissions = query.order_by(Commission.id.asc()).all() commissions = query.order_by(Commission.id.asc()).all()
subjects = Subject.query.order_by(Subject.name.asc()).all() subjects = Subject.query.order_by(Subject.name.asc()).all()
@@ -220,6 +222,13 @@ def get_commissions():
careers = Career.query.order_by(Career.name.asc()).all() careers = Career.query.order_by(Career.name.asc()).all()
careers_data = [{'id': cr.id, 'name': cr.name, 'code': cr.code} for cr in careers] careers_data = [{'id': cr.id, 'name': cr.name, 'code': cr.code} for cr in careers]
# Pre-cargar reservas activas para enriquecer con asignación de aula
reservations_by_comm = {}
all_res = Reservation.query.filter(Reservation.commission_id.isnot(None)).order_by(Reservation.start_time.asc()).all()
for r in all_res:
if r.commission_id not in reservations_by_comm:
reservations_by_comm[r.commission_id] = r
commissions_data = [] commissions_data = []
for c in commissions: for c in commissions:
if search: if search:
@@ -228,11 +237,25 @@ def get_commissions():
if search not in s_name and search not in c_code: if search not in s_name and search not in c_code:
continue continue
res = reservations_by_comm.get(c.id)
c_room = res.classroom if res else None
c_code_val = c_room.code if c_room else None
is_virt_room = bool(c_room.is_virtual or 'virtual' in (c_room.code or '').lower() or 'virtual' in (c_room.building or '').lower()) if c_room else False
has_v_link = bool(c.virtual_link and c.virtual_link.strip())
has_classroom = bool(c_code_val or has_v_link)
if unassigned_room in ['true', '1'] and has_classroom:
continue
if unassigned_room in ['false', '0'] and not has_classroom:
continue
career_name = c.career_name if hasattr(c, 'career_name') else 'Carrera General' career_name = c.career_name if hasattr(c, 'career_name') else 'Carrera General'
career_names = c.career_names if hasattr(c, 'career_names') else career_name career_names = c.career_names if hasattr(c, 'career_names') else career_name
careers_list = c.careers if hasattr(c, 'careers') else [] careers_list = c.careers if hasattr(c, 'careers') else []
career_id_val = c.career_id if hasattr(c, 'career_id') else (c.subject.career_id if c.subject else None) career_id_val = c.career_id if hasattr(c, 'career_id') else (c.subject.career_id if c.subject else None)
display_room = c_code_val or ('Campus Virtual' if has_v_link else 'Sin Aula')
commissions_data.append({ commissions_data.append({
'id': c.id, 'id': c.id,
'code': c.code, 'code': c.code,
@@ -256,7 +279,11 @@ def get_commissions():
'max_students': c.max_students or 35, 'max_students': c.max_students or 35,
'current_students': getattr(c, 'current_students', 0) or 0, 'current_students': getattr(c, 'current_students', 0) or 0,
'active': c.active, 'active': c.active,
'virtual_link': getattr(c, 'virtual_link', '') or '' 'virtual_link': getattr(c, 'virtual_link', '') or '',
'has_classroom': has_classroom,
'classroom_name': display_room,
'classroom_code': c_code_val,
'is_virtual': is_virt_room or has_v_link
}) })
subjects_data = [] subjects_data = []
+37 -3
View File
@@ -150,7 +150,7 @@ def get_stats():
upcoming_reservations = [serialize_reservation(r) for r in upcoming_reservations_q] upcoming_reservations = [serialize_reservation(r) for r in upcoming_reservations_q]
milestones = [serialize_milestone(m) for m in milestones_q] milestones = [serialize_milestone(m) for m in milestones_q]
# ---- Bedelía: Comisiones sin aula asignada (semana y mes) ---- # ---- Bedelía: Comisiones sin aula asignada (semana, mes y general) ----
import calendar import calendar
# Calcular rango de semana actual (lunes a domingo) # Calcular rango de semana actual (lunes a domingo)
today_dt = datetime.utcnow() today_dt = datetime.utcnow()
@@ -158,6 +158,13 @@ def get_stats():
week_start = week_start.replace(hour=0, minute=0, second=0, microsecond=0) week_start = week_start.replace(hour=0, minute=0, second=0, microsecond=0)
week_end = week_start + timedelta(days=6, hours=23, minutes=59, seconds=59) week_end = week_start + timedelta(days=6, hours=23, minutes=59, seconds=59)
# Reservas de la semana actual completa para Bedelía
week_reservations_q = Reservation.query.filter(
Reservation.start_time >= week_start,
Reservation.start_time <= week_end
).order_by(Reservation.start_time.asc()).all()
week_schedule_list = [serialize_reservation(r) for r in week_reservations_q]
# Calcular rango del mes actual # Calcular rango del mes actual
month_start = today_dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0) month_start = today_dt.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
last_day = calendar.monthrange(today_dt.year, today_dt.month)[1] last_day = calendar.monthrange(today_dt.year, today_dt.month)[1]
@@ -183,10 +190,18 @@ def get_stats():
Reservation.start_time <= month_end Reservation.start_time <= month_end
).distinct().all() ).distinct().all()
) )
# IDs de comisiones que tienen AL MENOS una reserva en general
comm_ids_with_any_res = set(
r[0] for r in db.session.query(Reservation.commission_id).filter(
Reservation.commission_id.isnot(None)
).distinct().all()
)
unassigned_commissions_week = [] unassigned_commissions_week = []
unassigned_commissions_month = [] unassigned_commissions_month = []
unassigned_commissions_general = []
for comm in all_active_commissions: for comm in all_active_commissions:
has_v_link = bool(comm.virtual_link and comm.virtual_link.strip())
comm_data = { comm_data = {
'id': comm.id, 'id': comm.id,
'code': comm.code, 'code': comm.code,
@@ -197,14 +212,24 @@ def get_stats():
'schedule': comm.schedule or 'Sin horario', 'schedule': comm.schedule or 'Sin horario',
'shift': comm.shift or 'Sin turno', 'shift': comm.shift or 'Sin turno',
'max_students': comm.max_students, 'max_students': comm.max_students,
'current_students': comm.current_students 'current_students': comm.current_students,
'virtual_link': comm.virtual_link or '',
'has_virtual_link': has_v_link
} }
if comm.id not in comm_ids_with_res_week: if comm.id not in comm_ids_with_res_week:
unassigned_commissions_week.append(comm_data) unassigned_commissions_week.append(comm_data)
if comm.id not in comm_ids_with_res_month: if comm.id not in comm_ids_with_res_month:
unassigned_commissions_month.append(comm_data) unassigned_commissions_month.append(comm_data)
if comm.id not in comm_ids_with_any_res and not has_v_link:
unassigned_commissions_general.append(comm_data)
# ---- Bedelía: Aulas disponibles (sin reservas) en la semana y mes ---- # ---- Bedelía: Aulas disponibles (sin reservas) hoy, semana y mes ----
classroom_ids_used_today = set(
r[0] for r in db.session.query(Reservation.classroom_id).filter(
Reservation.classroom_id.isnot(None),
func.date(Reservation.start_time) == today
).distinct().all()
)
classroom_ids_used_week = set( classroom_ids_used_week = set(
r[0] for r in db.session.query(Reservation.classroom_id).filter( r[0] for r in db.session.query(Reservation.classroom_id).filter(
Reservation.classroom_id.isnot(None), Reservation.classroom_id.isnot(None),
@@ -220,6 +245,7 @@ def get_stats():
).distinct().all() ).distinct().all()
) )
available_classrooms_today = []
available_classrooms_week = [] available_classrooms_week = []
available_classrooms_month = [] available_classrooms_month = []
for c in all_active_classrooms: for c in all_active_classrooms:
@@ -231,6 +257,8 @@ def get_stats():
'capacity': c.capacity, 'capacity': c.capacity,
'is_virtual': getattr(c, 'is_virtual', False) or 'virtual' in (c.building or '').lower() or 'virtual' in (c.code or '').lower() 'is_virtual': getattr(c, 'is_virtual', False) or 'virtual' in (c.building or '').lower() or 'virtual' in (c.code or '').lower()
} }
if c.id not in classroom_ids_used_today:
available_classrooms_today.append(c_data)
if c.id not in classroom_ids_used_week: if c.id not in classroom_ids_used_week:
available_classrooms_week.append(c_data) available_classrooms_week.append(c_data)
if c.id not in classroom_ids_used_month: if c.id not in classroom_ids_used_month:
@@ -257,9 +285,12 @@ def get_stats():
audit_data = [] audit_data = []
pending_reservations = [] pending_reservations = []
today_schedule_list = [] today_schedule_list = []
week_schedule_list = []
upcoming_reservations = [] upcoming_reservations = []
unassigned_commissions_week = [] unassigned_commissions_week = []
unassigned_commissions_month = [] unassigned_commissions_month = []
unassigned_commissions_general = []
available_classrooms_today = []
available_classrooms_week = [] available_classrooms_week = []
available_classrooms_month = [] available_classrooms_month = []
total_active_commissions = 0 total_active_commissions = 0
@@ -306,6 +337,7 @@ def get_stats():
'monthly_data': monthly_data, 'monthly_data': monthly_data,
'pending_reservations': pending_reservations, 'pending_reservations': pending_reservations,
'today_schedule_list': today_schedule_list, 'today_schedule_list': today_schedule_list,
'week_schedule_list': week_schedule_list,
'upcoming_reservations': upcoming_reservations, 'upcoming_reservations': upcoming_reservations,
'milestones': milestones, 'milestones': milestones,
'ui': { 'ui': {
@@ -314,6 +346,8 @@ def get_stats():
'bedelia': { 'bedelia': {
'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,
'available_classrooms_today': available_classrooms_today,
'available_classrooms_week': available_classrooms_week, 'available_classrooms_week': available_classrooms_week,
'available_classrooms_month': available_classrooms_month 'available_classrooms_month': available_classrooms_month
} }
+1 -1
View File
@@ -426,7 +426,7 @@ class GoogleSheetsImporter:
# Calculate current semester dates (anchored on academic year 2026) # Calculate current semester dates (anchored on academic year 2026)
base_monday = date(2026, 8, 31) base_monday = date(2026, 8, 31)
weeks_to_generate = 4 # Generar reservas para 4 semanas consecutivas weeks_to_generate = 16 # Generar reservas para 16 semanas (cuatrimestre completo Ago - Dic 2026)
for rec, day_idx in all_raw_records: for rec, day_idx in all_raw_records:
try: try:
+8 -1
View File
@@ -833,6 +833,7 @@ const handleCommissionsList = async (req, res) => {
const career_id = req.query.career_id || ''; const career_id = req.query.career_id || '';
const shift = req.query.shift || ''; const shift = req.query.shift || '';
const active = req.query.active || ''; const active = req.query.active || '';
const unassigned_room = req.query.unassigned_room || '';
const created = req.query.created === '1'; const created = req.query.created === '1';
let commissions = []; let commissions = [];
@@ -843,7 +844,7 @@ const handleCommissionsList = async (req, res) => {
try { try {
const [cRes, uRes] = await Promise.allSettled([ const [cRes, uRes] = await Promise.allSettled([
req.apiClient.get('/commissions', { params: { search, subject_id, career_id, shift, active } }), req.apiClient.get('/commissions', { params: { search, subject_id, career_id, shift, active, unassigned_room } }),
req.apiClient.get('/users') req.apiClient.get('/users')
]); ]);
@@ -853,6 +854,11 @@ const handleCommissionsList = async (req, res) => {
get_full_code: () => c.full_code || c.code, get_full_code: () => c.full_code || c.code,
career_id: c.career_id, career_id: c.career_id,
career_name: c.career_name || 'Carrera General', career_name: c.career_name || 'Carrera General',
classroom_name: c.classroom_name || 'Sin Aula Asignada',
has_classroom: Boolean(c.has_classroom),
is_virtual: Boolean(c.is_virtual),
virtual_link: c.virtual_link || '',
schedule: c.schedule || 'Sin horario',
subject: { subject: {
id: c.subject_id, id: c.subject_id,
name: c.subject_name, name: c.subject_name,
@@ -907,6 +913,7 @@ const handleCommissionsList = async (req, res) => {
career_filter: career_id ? parseInt(career_id, 10) : '', career_filter: career_id ? parseInt(career_id, 10) : '',
shift_filter: shift, shift_filter: shift,
active_filter: active, active_filter: active,
unassigned_room_filter: unassigned_room,
created, created,
msg: req.query.msg || (created ? 'created' : ''), msg: req.query.msg || (created ? 'created' : ''),
error: req.query.error || '', error: req.query.error || '',
+4
View File
@@ -107,11 +107,15 @@ router.get('/', async (req, res) => {
] ]
}; };
} else if (role === 'bedelia') { } else if (role === 'bedelia') {
const apiWeekSchedule = Array.isArray(apiData.week_schedule_list) ? apiData.week_schedule_list : [];
role_data = { role_data = {
pending_reservations: apiPending || [], pending_reservations: apiPending || [],
today_schedule_list: apiTodaySchedule || [], today_schedule_list: apiTodaySchedule || [],
week_schedule_list: apiWeekSchedule,
unassigned_commissions_week: bedeliaData.unassigned_commissions_week || [], unassigned_commissions_week: bedeliaData.unassigned_commissions_week || [],
unassigned_commissions_month: bedeliaData.unassigned_commissions_month || [], unassigned_commissions_month: bedeliaData.unassigned_commissions_month || [],
unassigned_commissions_general: bedeliaData.unassigned_commissions_general || [],
available_classrooms_today: bedeliaData.available_classrooms_today || [],
available_classrooms_week: bedeliaData.available_classrooms_week || [], available_classrooms_week: bedeliaData.available_classrooms_week || [],
available_classrooms_month: bedeliaData.available_classrooms_month || [] available_classrooms_month: bedeliaData.available_classrooms_month || []
}; };
+19 -2
View File
@@ -164,11 +164,21 @@ router.get('/list_reservations', handleReservationsList);
// 4. Vista de Hoy (Cartelera del Día) // 4. Vista de Hoy (Cartelera del Día)
const handleTodaySchedule = async (req, res) => { const handleTodaySchedule = async (req, res) => {
try { try {
const todayStr = req.query.date || '2026-09-18'; const defaultTodayStr = new Date().toISOString().split('T')[0];
const todayStr = req.query.date || defaultTodayStr;
const hide_virtual = req.query.hide_virtual === '1' || req.query.hide_virtual === 'true'; const hide_virtual = req.query.hide_virtual === '1' || req.query.hide_virtual === 'true';
const floor_filter = req.query.floor || ''; const floor_filter = req.query.floor || '';
const shift_filter = req.query.shift || ''; const shift_filter = req.query.shift || '';
// Fechas anterior y siguiente para navegación
const currentDateObj = new Date(todayStr + 'T00:00:00');
const prevDateObj = new Date(currentDateObj);
prevDateObj.setDate(prevDateObj.getDate() - 1);
const nextDateObj = new Date(currentDateObj);
nextDateObj.setDate(nextDateObj.getDate() + 1);
const prevDateStr = prevDateObj.toISOString().split('T')[0];
const nextDateStr = nextDateObj.toISOString().split('T')[0];
const params = { const params = {
start_date: todayStr, start_date: todayStr,
end_date: todayStr end_date: todayStr
@@ -238,6 +248,9 @@ const handleTodaySchedule = async (req, res) => {
time_blocks, time_blocks,
stats, stats,
today: todayStr, today: todayStr,
prev_date: prevDateStr,
next_date: nextDateStr,
default_today: defaultTodayStr,
hide_virtual, hide_virtual,
floor_filter, floor_filter,
shift_filter, shift_filter,
@@ -246,12 +259,16 @@ const handleTodaySchedule = async (req, res) => {
}); });
} catch (error) { } catch (error) {
console.error('Error fetching today reservations:', error.message); console.error('Error fetching today reservations:', error.message);
const fallbackToday = new Date().toISOString().split('T')[0];
res.render('schedule/today', { res.render('schedule/today', {
title: 'Cartelera del Día (Offline)', title: 'Cartelera del Día (Offline)',
reservations: [], reservations: [],
time_blocks: {}, time_blocks: {},
stats: { total_reservations: 0, confirmed: 0, pending: 0, occupied_classrooms: 0, total_classrooms: 59 }, stats: { total_reservations: 0, confirmed: 0, pending: 0, occupied_classrooms: 0, total_classrooms: 59 },
today: '2026-09-18', today: fallbackToday,
prev_date: fallbackToday,
next_date: fallbackToday,
default_today: fallbackToday,
hide_virtual: false, hide_virtual: false,
floor_filter: '', floor_filter: '',
shift_filter: '', shift_filter: '',
+34 -3
View File
@@ -134,6 +134,16 @@
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<div class="col-6 col-md-2">
<label class="form-label small fw-semibold mb-1">
<i class="bi bi-door-open text-primary me-1"></i>Aula / Espacio
</label>
<select name="unassigned_room" class="form-select form-select-sm" id="unassigned-room-filter">
<option value="" {% if not unassigned_room_filter %}selected{% endif %}>Todas las comisiones</option>
<option value="true" {% if unassigned_room_filter == 'true' %}selected{% endif %}>⚠️ Sin Aula Asignada</option>
<option value="false" {% if unassigned_room_filter == 'false' %}selected{% endif %}>✅ Con Aula Asignada</option>
</select>
</div>
<div class="col-6 col-md-1"> <div class="col-6 col-md-1">
<label class="form-label small fw-semibold mb-1">Estado</label> <label class="form-label small fw-semibold mb-1">Estado</label>
<select name="active" class="form-select form-select-sm" id="active-filter"> <select name="active" class="form-select form-select-sm" id="active-filter">
@@ -142,9 +152,9 @@
<option value="" {% if not active_filter %}selected{% endif %}>Todas</option> <option value="" {% if not active_filter %}selected{% endif %}>Todas</option>
</select> </select>
</div> </div>
<div class="col-12 col-md-2 d-flex gap-2"> <div class="col-12 col-md-1 d-flex gap-1">
<button type="submit" class="btn btn-primary btn-sm flex-fill" id="filter-btn"> <button type="submit" class="btn btn-primary btn-sm flex-fill" id="filter-btn" title="Aplicar filtros">
<i class="bi bi-funnel me-1"></i>Filtrar <i class="bi bi-funnel"></i>
</button> </button>
<a href="/admin/commissions_list" class="btn btn-outline-secondary btn-sm" title="Limpiar filtros"> <a href="/admin/commissions_list" class="btn btn-outline-secondary btn-sm" title="Limpiar filtros">
<i class="bi bi-x"></i> <i class="bi bi-x"></i>
@@ -171,6 +181,7 @@
<tr> <tr>
<th class="ps-3">Comisión</th> <th class="ps-3">Comisión</th>
<th>Asignatura</th> <th>Asignatura</th>
<th>Espacio / Aula</th>
<th>Docente</th> <th>Docente</th>
<th class="text-center">Turno</th> <th class="text-center">Turno</th>
<th class="text-center">Alumnos</th> <th class="text-center">Alumnos</th>
@@ -200,6 +211,26 @@
<small class="text-muted ms-1">{{ comm.semester }} {{ comm.year }}</small> <small class="text-muted ms-1">{{ comm.semester }} {{ comm.year }}</small>
</div> </div>
</td> </td>
<td>
{% if comm.has_classroom %}
{% if comm.is_virtual %}
<span class="badge bg-info-subtle text-info border">
<i class="bi bi-camera-video me-1"></i>{{ comm.classroom_name }}
</span>
{% if comm.virtual_link %}
<a href="{{ comm.virtual_link }}" target="_blank" class="text-info ms-1 small" title="Enlace Videoconferencia"><i class="bi bi-box-arrow-up-right"></i></a>
{% endif %}
{% else %}
<span class="badge bg-success-subtle text-success border font-monospace">
<i class="bi bi-door-open me-1"></i>{{ comm.classroom_name }}
</span>
{% endif %}
{% else %}
<span class="badge bg-danger-subtle text-danger border">
<i class="bi bi-exclamation-triangle-fill me-1"></i>Sin Aula
</span>
{% endif %}
</td>
<td> <td>
{% if comm.teachers and comm.teachers | length > 0 %} {% if comm.teachers and comm.teachers | length > 0 %}
<div class="d-flex flex-column gap-1"> <div class="d-flex flex-column gap-1">
+293 -8
View File
@@ -637,6 +637,171 @@
</div> </div>
</div> </div>
<!-- ========================= Panel: Cartelera Operativa & Agenda de Clases (Hoy y Semana) ========================= -->
<div class="card border-0 shadow-sm mb-4" id="bedelia-reservations-schedule">
<div class="card-header bg-body-tertiary border-0 py-3 d-flex justify-content-between align-items-center flex-wrap gap-2">
<div class="d-flex align-items-center gap-2">
<i class="bi bi-calendar-check-fill text-primary fs-5"></i>
<div>
<h5 class="mb-0 h6 fw-bold">Cartelera Operativa & Agenda de Clases</h5>
<small class="text-muted">Control de reservas áulicas presenciales y virtuales activas</small>
</div>
</div>
<div class="d-flex gap-2 align-items-center flex-wrap">
<div class="btn-group btn-group-sm" role="group" id="bedeliaScheduleSwitcher">
<button type="button" class="btn btn-outline-primary active" data-view="today" onclick="switchBedeliaScheduleView('today')">
<i class="bi bi-calendar-day me-1"></i>Clases de Hoy
<span class="badge bg-primary ms-1" id="bedeliaTodayBadge">{{ role_data.today_schedule_list | length }}</span>
</button>
<button type="button" class="btn btn-outline-primary" data-view="week" onclick="switchBedeliaScheduleView('week')">
<i class="bi bi-calendar-week me-1"></i>Esta Semana
<span class="badge bg-primary ms-1" id="bedeliaWeekBadge">{{ role_data.week_schedule_list | length }}</span>
</button>
</div>
<a href="/schedule/today_schedule" class="btn btn-sm btn-outline-info">
<i class="bi bi-clock-history me-1"></i>Cartelera en Vivo
</a>
<a href="/schedule/calendar_view" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-calendar3 me-1"></i>Calendario Semanal
</a>
</div>
</div>
<div class="card-body p-0">
<!-- Tabla Clases de Hoy -->
<div id="bedeliaScheduleToday">
{% if role_data.today_schedule_list and role_data.today_schedule_list | length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 small">
<thead class="table-light">
<tr>
<th class="ps-3">Horario</th>
<th>Aula / Espacio</th>
<th>Asignatura</th>
<th>Comisión / Turno</th>
<th>Docente</th>
<th class="text-center">Estado</th>
<th class="text-end pe-3">Acción</th>
</tr>
</thead>
<tbody>
{% for r in role_data.today_schedule_list %}
<tr>
<td class="ps-3 font-monospace">
<strong>{{ r.start_time }}</strong> - {{ r.end_time }} hs
</td>
<td>
{% if r.classroom.is_virtual %}
<span class="badge bg-info-subtle text-info border">
<i class="bi bi-camera-video me-1"></i>{{ r.classroom.code }}
</span>
{% if r.virtual_link %}
<a href="{{ r.virtual_link }}" target="_blank" class="btn btn-xs btn-outline-info ms-1 py-0 px-1" title="Unirse a videoconferencia">
<i class="bi bi-box-arrow-up-right"></i> Link
</a>
{% endif %}
{% else %}
<span class="badge bg-primary-subtle text-primary border font-monospace">
<i class="bi bi-door-open me-1"></i>{{ r.classroom.code }}
</span>
{% endif %}
</td>
<td>
<div class="fw-semibold text-body">{{ r.subject_name }}</div>
{% if r.subject_code %}<small class="text-muted font-monospace">{{ r.subject_code }}</small>{% endif %}
</td>
<td>
<span class="badge bg-secondary-subtle text-secondary border me-1">{{ r.commission.code }}</span>
<span class="badge bg-light text-dark border">{{ r.shift }}</span>
</td>
<td class="small">{{ r.user.name }}</td>
<td class="text-center">
<span class="badge bg-success-subtle text-success border">Confirmada</span>
</td>
<td class="text-end pe-3">
<a href="/schedule/today_schedule" class="btn btn-sm btn-outline-primary py-0 px-2" title="Ver en cartelera del día">
<i class="bi bi-eye me-1"></i>Ver
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-4">
<i class="bi bi-calendar-x text-muted fs-1 d-block mb-2"></i>
<h6 class="text-secondary fw-bold">No hay clases programadas para el día de hoy</h6>
<p class="text-muted small mb-0">Consulte el cronograma semanal o cargue una nueva reserva si corresponde.</p>
</div>
{% endif %}
</div>
<!-- Tabla Agenda Semanal -->
<div id="bedeliaScheduleWeek" style="display: none;">
{% if role_data.week_schedule_list and role_data.week_schedule_list | length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 small">
<thead class="table-light">
<tr>
<th class="ps-3">Fecha</th>
<th>Horario</th>
<th>Aula / Espacio</th>
<th>Asignatura</th>
<th>Comisión / Turno</th>
<th>Docente</th>
<th class="text-end pe-3">Acción</th>
</tr>
</thead>
<tbody>
{% for r in role_data.week_schedule_list %}
<tr>
<td class="ps-3 font-monospace fw-bold text-primary">
{{ r.date_display }}
</td>
<td class="font-monospace">
{{ r.start_time }} - {{ r.end_time }} hs
</td>
<td>
{% if r.classroom.is_virtual %}
<span class="badge bg-info-subtle text-info border">
<i class="bi bi-camera-video me-1"></i>{{ r.classroom.code }}
</span>
{% else %}
<span class="badge bg-primary-subtle text-primary border font-monospace">
<i class="bi bi-door-open me-1"></i>{{ r.classroom.code }}
</span>
{% endif %}
</td>
<td>
<div class="fw-semibold text-body">{{ r.subject_name }}</div>
{% if r.subject_code %}<small class="text-muted font-monospace">{{ r.subject_code }}</small>{% endif %}
</td>
<td>
<span class="badge bg-secondary-subtle text-secondary border me-1">{{ r.commission.code }}</span>
<span class="badge bg-light text-dark border">{{ r.shift }}</span>
</td>
<td class="small">{{ r.user.name }}</td>
<td class="text-end pe-3">
<a href="/schedule/calendar_view" class="btn btn-sm btn-outline-secondary py-0 px-2" title="Ver en calendario">
<i class="bi bi-calendar3 me-1"></i>Calendario
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-4">
<i class="bi bi-calendar-x text-muted fs-1 d-block mb-2"></i>
<h6 class="text-secondary fw-bold">No hay clases programadas para esta semana</h6>
<p class="text-muted small mb-0">Puede importar cursadas desde Google Sheets o cargar reservas manualmente.</p>
</div>
{% endif %}
</div>
</div>
</div>
<!-- ========================= Panel: Comisiones Sin Reserva (Semana/Mes) ========================= --> <!-- ========================= Panel: Comisiones Sin Reserva (Semana/Mes) ========================= -->
<div class="card border-0 shadow-sm mb-4" id="bedelia-unassigned-commissions"> <div class="card border-0 shadow-sm mb-4" id="bedelia-unassigned-commissions">
<div class="card-header bg-body-tertiary border-0 py-3 d-flex justify-content-between align-items-center flex-wrap gap-2"> <div class="card-header bg-body-tertiary border-0 py-3 d-flex justify-content-between align-items-center flex-wrap gap-2">
@@ -653,6 +818,10 @@
<i class="bi bi-calendar-week me-1"></i>Esta Semana <i class="bi bi-calendar-week me-1"></i>Esta Semana
<span class="badge bg-danger ms-1" id="commWeekBadge">{{ role_data.unassigned_commissions_week | length }}</span> <span class="badge bg-danger ms-1" id="commWeekBadge">{{ role_data.unassigned_commissions_week | length }}</span>
</button> </button>
<button type="button" class="btn btn-outline-danger" data-period="general" onclick="switchCommPeriod('general')">
<i class="bi bi-exclamation-triangle-fill me-1"></i>Sin Aula Física ni Virtual
<span class="badge bg-danger ms-1" id="commGeneralBadge">{{ role_data.unassigned_commissions_general | length }}</span>
</button>
<button type="button" class="btn btn-outline-danger" data-period="month" onclick="switchCommPeriod('month')"> <button type="button" class="btn btn-outline-danger" data-period="month" onclick="switchCommPeriod('month')">
<i class="bi bi-calendar-month me-1"></i>Este Mes <i class="bi bi-calendar-month me-1"></i>Este Mes
<span class="badge bg-danger ms-1" id="commMonthBadge">{{ role_data.unassigned_commissions_month | length }}</span> <span class="badge bg-danger ms-1" id="commMonthBadge">{{ role_data.unassigned_commissions_month | length }}</span>
@@ -769,12 +938,63 @@
<h6 class="text-success fw-bold">¡Todas las comisiones tienen reserva este mes!</h6> <h6 class="text-success fw-bold">¡Todas las comisiones tienen reserva este mes!</h6>
<p class="text-muted small mb-0">No hay comisiones activas sin aula reservada en el mes actual.</p> <p class="text-muted small mb-0">No hay comisiones activas sin aula reservada en el mes actual.</p>
</div> </div>
<!-- Tabla General (Sin Aula Presencial ni Virtual) -->
<div id="commTableGeneral" style="display: none;">
{% if role_data.unassigned_commissions_general and role_data.unassigned_commissions_general | length > 0 %}
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 small">
<thead class="table-light">
<tr>
<th class="ps-3">Código</th>
<th>Materia</th>
<th>Docente</th>
<th>Horario Programado</th>
<th>Turno</th>
<th>Cupo</th>
<th class="text-end pe-3">Acción</th>
</tr>
</thead>
<tbody>
{% for comm in role_data.unassigned_commissions_general %}
<tr>
<td class="ps-3">
<span class="badge bg-danger-subtle text-danger border font-monospace">{{ comm.full_code }}</span>
</td>
<td>
<div class="fw-semibold text-body">{{ comm.subject_name }}</div>
<small class="text-muted font-monospace">{{ comm.subject_code }}</small>
</td>
<td class="small">{{ comm.teacher_name }}</td>
<td>
<span class="badge bg-body-tertiary text-body border"><i class="bi bi-clock me-1"></i>{{ comm.schedule }}</span>
</td>
<td><span class="badge bg-info-subtle text-info-emphasis border">{{ comm.shift }}</span></td>
<td class="font-monospace">{{ comm.current_students }}/{{ comm.max_students }}</td>
<td class="text-end pe-3">
<a href="/schedule/add_reservation?commission_id={{ comm.id }}" class="btn btn-sm btn-outline-success py-0 px-2" title="Asignar aula a esta comisión">
<i class="bi bi-plus-circle me-1"></i>Asignar
</a>
<a href="/admin/commission_detail?id={{ comm.id }}" class="btn btn-sm btn-outline-primary py-0 px-2 ms-1" title="Ver detalle">
<i class="bi bi-eye me-1"></i>Detalle
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-4">
<i class="bi bi-check-circle-fill text-success fs-1 d-block mb-2"></i>
<h6 class="text-success fw-bold">¡Excelente! Todas las comisiones tienen aula física o virtual asignada</h6>
<p class="text-muted small mb-0">No se detectaron comisiones huérfanas sin espacio asignado.</p>
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
</div> </div>
<!-- ========================= Panel: Aulas Disponibles (Semana/Mes) ========================= --> <!-- ========================= Panel: Aulas Disponibles (Hoy / Semana / Mes) ========================= -->
<div class="card border-0 shadow-sm mb-4" id="bedelia-available-classrooms"> <div class="card border-0 shadow-sm mb-4" id="bedelia-available-classrooms">
<div class="card-header bg-body-tertiary border-0 py-3 d-flex justify-content-between align-items-center flex-wrap gap-2"> <div class="card-header bg-body-tertiary border-0 py-3 d-flex justify-content-between align-items-center flex-wrap gap-2">
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-2">
@@ -786,7 +1006,11 @@
</div> </div>
<div class="d-flex gap-2 align-items-center flex-wrap"> <div class="d-flex gap-2 align-items-center flex-wrap">
<div class="btn-group btn-group-sm" role="group" id="classroomPeriodSwitcher"> <div class="btn-group btn-group-sm" role="group" id="classroomPeriodSwitcher">
<button type="button" class="btn btn-outline-success active" data-period="week" onclick="switchClassroomPeriod('week')"> <button type="button" class="btn btn-outline-success active" data-period="today" onclick="switchClassroomPeriod('today')">
<i class="bi bi-calendar-day me-1"></i>Hoy
<span class="badge bg-success ms-1" id="classTodayBadge">{{ role_data.available_classrooms_today | length }}</span>
</button>
<button type="button" class="btn btn-outline-success" data-period="week" onclick="switchClassroomPeriod('week')">
<i class="bi bi-calendar-week me-1"></i>Esta Semana <i class="bi bi-calendar-week me-1"></i>Esta Semana
<span class="badge bg-success ms-1" id="classWeekBadge">{{ role_data.available_classrooms_week | length }}</span> <span class="badge bg-success ms-1" id="classWeekBadge">{{ role_data.available_classrooms_week | length }}</span>
</button> </button>
@@ -801,8 +1025,49 @@
</div> </div>
</div> </div>
<div class="card-body p-3"> <div class="card-body p-3">
<!-- Vista Hoy -->
<div id="classroomGridToday">
{% if role_data.available_classrooms_today and role_data.available_classrooms_today | length > 0 %}
<div class="row g-2">
{% for aula in role_data.available_classrooms_today %}
<div class="col-sm-6 col-md-4 col-lg-3">
<a href="/schedule/add_reservation?classroom_id={{ aula.id }}" class="text-decoration-none text-reset d-block h-100">
<div class="p-3 rounded border h-100 transition-all {% if aula.is_virtual %}bg-info bg-opacity-10 border-info-subtle{% else %}bg-success bg-opacity-10 border-success-subtle{% endif %}">
<div class="d-flex justify-content-between align-items-start mb-2">
<span class="badge {% if aula.is_virtual %}bg-info-subtle text-info{% else %}bg-success-subtle text-success{% endif %} border font-monospace fw-bold">
{{ aula.code }}
</span>
{% if aula.is_virtual %}
<i class="bi bi-camera-video text-info"></i>
{% else %}
<i class="bi bi-door-open text-success"></i>
{% endif %}
</div>
<div class="small text-muted mb-1">
<i class="bi bi-building me-1"></i>{{ aula.building }}{% if aula.floor %} · {{ aula.floor }}{% endif %}
</div>
<div class="d-flex justify-content-between align-items-center">
<span class="small fw-semibold text-body">
<i class="bi bi-people-fill me-1"></i>Cap: {{ aula.capacity }}
</span>
<span class="badge bg-success text-white small"><i class="bi bi-plus-circle me-1"></i>Asignar</span>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-center py-4">
<i class="bi bi-calendar-check-fill text-primary fs-1 d-block mb-2"></i>
<h6 class="text-primary fw-bold">¡Todas las aulas están ocupadas en el día de hoy!</h6>
<p class="text-muted small mb-0">Consulte el cronograma por piso o la cartelera del día.</p>
</div>
{% endif %}
</div>
<!-- Vista Semana --> <!-- Vista Semana -->
<div id="classroomGridWeek"> <div id="classroomGridWeek" style="display: none;">
{% if role_data.available_classrooms_week and role_data.available_classrooms_week | length > 0 %} {% if role_data.available_classrooms_week and role_data.available_classrooms_week | length > 0 %}
<div class="row g-2"> <div class="row g-2">
{% for aula in role_data.available_classrooms_week %} {% for aula in role_data.available_classrooms_week %}
@@ -1577,18 +1842,38 @@ document.querySelectorAll('[data-color]').forEach(function(el) {
if (color) el.style.setProperty('background-color', color, 'important'); if (color) el.style.setProperty('background-color', color, 'important');
}); });
// Bedelía: Switchers de período para paneles de Comisiones y Aulas // Bedelía: Switcher para Cartelera y Agenda de Clases
function switchBedeliaScheduleView(view) {
const todayEl = document.getElementById('bedeliaScheduleToday');
const weekEl = document.getElementById('bedeliaScheduleWeek');
if (todayEl) todayEl.style.display = view === 'today' ? 'block' : 'none';
if (weekEl) weekEl.style.display = view === 'week' ? 'block' : 'none';
document.querySelectorAll('#bedeliaScheduleSwitcher button').forEach(function(btn) {
btn.classList.toggle('active', btn.getAttribute('data-view') === view);
});
}
// Bedelía: Switchers de período para paneles de Comisiones
function switchCommPeriod(period) { function switchCommPeriod(period) {
document.getElementById('commTableWeek').style.display = period === 'week' ? 'block' : 'none'; const weekEl = document.getElementById('commTableWeek');
document.getElementById('commTableMonth').style.display = period === 'month' ? 'block' : 'none'; const genEl = document.getElementById('commTableGeneral');
const monthEl = document.getElementById('commTableMonth');
if (weekEl) weekEl.style.display = period === 'week' ? 'block' : 'none';
if (genEl) genEl.style.display = period === 'general' ? 'block' : 'none';
if (monthEl) monthEl.style.display = period === 'month' ? 'block' : 'none';
document.querySelectorAll('#commPeriodSwitcher button').forEach(function(btn) { document.querySelectorAll('#commPeriodSwitcher button').forEach(function(btn) {
btn.classList.toggle('active', btn.getAttribute('data-period') === period); btn.classList.toggle('active', btn.getAttribute('data-period') === period);
}); });
} }
// Bedelía: Switchers de período para paneles de Aulas
function switchClassroomPeriod(period) { function switchClassroomPeriod(period) {
document.getElementById('classroomGridWeek').style.display = period === 'week' ? 'block' : 'none'; const todayEl = document.getElementById('classroomGridToday');
document.getElementById('classroomGridMonth').style.display = period === 'month' ? 'block' : 'none'; const weekEl = document.getElementById('classroomGridWeek');
const monthEl = document.getElementById('classroomGridMonth');
if (todayEl) todayEl.style.display = period === 'today' ? 'block' : 'none';
if (weekEl) weekEl.style.display = period === 'week' ? 'block' : 'none';
if (monthEl) monthEl.style.display = period === 'month' ? 'block' : 'none';
document.querySelectorAll('#classroomPeriodSwitcher button').forEach(function(btn) { document.querySelectorAll('#classroomPeriodSwitcher button').forEach(function(btn) {
btn.classList.toggle('active', btn.getAttribute('data-period') === period); btn.classList.toggle('active', btn.getAttribute('data-period') === period);
}); });
+25 -4
View File
@@ -88,8 +88,29 @@
<div class="card border-0 shadow-sm mb-4"> <div class="card border-0 shadow-sm mb-4">
<div class="card-body p-3"> <div class="card-body p-3">
<form method="GET" action="/schedule/today_schedule" class="row g-2 align-items-center"> <form method="GET" action="/schedule/today_schedule" class="row g-2 align-items-center">
<!-- Selector de Fecha y Navegación de Días -->
<div class="col-lg-3 col-md-6">
<label for="dateSelect" class="form-label small fw-bold text-muted mb-1">
<i class="bi bi-calendar-event text-primary me-1"></i>Fecha de la Cartelera
</label>
<div class="input-group input-group-sm">
<a href="/schedule/today_schedule?date={{ prev_date }}&floor={{ floor_filter }}&shift={{ shift_filter }}{% if hide_virtual %}&hide_virtual=1{% endif %}" class="btn btn-outline-secondary" title="Día Anterior">
<i class="bi bi-chevron-left"></i>
</a>
<input type="date" name="date" id="dateSelect" class="form-control form-control-sm font-monospace text-center fw-bold" value="{{ today }}" onchange="this.form.submit()">
<a href="/schedule/today_schedule?date={{ next_date }}&floor={{ floor_filter }}&shift={{ shift_filter }}{% if hide_virtual %}&hide_virtual=1{% endif %}" class="btn btn-outline-secondary" title="Día Siguiente">
<i class="bi bi-chevron-right"></i>
</a>
{% if today != default_today %}
<a href="/schedule/today_schedule" class="btn btn-primary btn-sm" title="Volver al Día de Hoy">
Hoy
</a>
{% endif %}
</div>
</div>
<!-- Filter by Floor --> <!-- Filter by Floor -->
<div class="col-lg-3 col-md-4"> <div class="col-lg-2 col-md-3">
<label for="floorSelect" class="form-label small fw-bold text-muted mb-1"> <label for="floorSelect" class="form-label small fw-bold text-muted mb-1">
<i class="bi bi-layers text-secondary me-1"></i>Piso / Planta <i class="bi bi-layers text-secondary me-1"></i>Piso / Planta
</label> </label>
@@ -104,7 +125,7 @@
</div> </div>
<!-- Filter by Turno --> <!-- Filter by Turno -->
<div class="col-lg-3 col-md-4"> <div class="col-lg-2 col-md-3">
<label for="shiftSelect" class="form-label small fw-bold text-muted mb-1"> <label for="shiftSelect" class="form-label small fw-bold text-muted mb-1">
<i class="bi bi-brightness-high text-warning me-1"></i>Turno <i class="bi bi-brightness-high text-warning me-1"></i>Turno
</label> </label>
@@ -116,7 +137,7 @@
</div> </div>
<!-- Hide Virtual Classrooms Toggle --> <!-- Hide Virtual Classrooms Toggle -->
<div class="col-lg-4 col-md-4 pt-md-3"> <div class="col-lg-3 col-md-6 pt-md-3">
<div class="form-check form-switch pt-1"> <div class="form-check form-switch pt-1">
<input class="form-check-input" type="checkbox" role="switch" name="hide_virtual" value="1" id="hideVirtualToday" {% if hide_virtual %}checked{% endif %} onchange="this.form.submit()"> <input class="form-check-input" type="checkbox" role="switch" name="hide_virtual" value="1" id="hideVirtualToday" {% if hide_virtual %}checked{% endif %} onchange="this.form.submit()">
<label class="form-check-label fw-semibold small text-dark" for="hideVirtualToday"> <label class="form-check-label fw-semibold small text-dark" for="hideVirtualToday">
@@ -127,7 +148,7 @@
</div> </div>
<!-- Actions --> <!-- Actions -->
<div class="col-lg-2 col-md-12 pt-md-3 text-lg-end d-flex gap-2"> <div class="col-lg-2 col-md-6 pt-md-3 text-lg-end d-flex gap-2">
<button type="submit" class="btn btn-primary btn-sm flex-fill"> <button type="submit" class="btn btn-primary btn-sm flex-fill">
<i class="bi bi-funnel me-1"></i>Filtrar <i class="bi bi-funnel me-1"></i>Filtrar
</button> </button>