feat(dashboard): add tomorrow filter to period switchers and schedule view v3.4.4
This commit is contained in:
@@ -6,7 +6,7 @@ from flask_babel import Babel, gettext as _
|
||||
from config.config import Config
|
||||
|
||||
# Initialize extensions
|
||||
__version__ = "3.4.3"
|
||||
__version__ = "3.4.4"
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
cors = CORS()
|
||||
|
||||
@@ -150,9 +150,13 @@ def get_stats():
|
||||
upcoming_reservations = [serialize_reservation(r) for r in upcoming_reservations_q]
|
||||
milestones = [serialize_milestone(m) for m in milestones_q]
|
||||
|
||||
# ---- Bedelía: Filtros completos de Aulas y Comisiones por Día, Semana y Mes ----
|
||||
# ---- Bedelía: Filtros completos de Aulas y Comisiones por Día (Hoy), Mañana, Semana y Mes ----
|
||||
import calendar
|
||||
today_dt = datetime.utcnow()
|
||||
tomorrow_dt = today_dt + timedelta(days=1)
|
||||
tomorrow_start = tomorrow_dt.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
tomorrow_end = tomorrow_dt.replace(hour=23, minute=59, second=59, microsecond=0)
|
||||
|
||||
week_start = today_dt - timedelta(days=today_dt.weekday()) # Lunes
|
||||
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)
|
||||
@@ -166,11 +170,16 @@ def get_stats():
|
||||
meses_esp = ['', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']
|
||||
weekday_name = dias_esp[today_dt.weekday()]
|
||||
month_name = meses_esp[today_dt.month]
|
||||
tomorrow_weekday_name = dias_esp[tomorrow_dt.weekday()]
|
||||
tomorrow_month_name = meses_esp[tomorrow_dt.month]
|
||||
|
||||
date_labels = {
|
||||
'today': f"Hoy · {weekday_name} {today_dt.strftime('%d/%m/%Y')}",
|
||||
'today_short': f"{weekday_name} {today_dt.strftime('%d/%m')}",
|
||||
'today_full': f"{weekday_name}, {today_dt.day} de {month_name} de {today_dt.year}",
|
||||
'tomorrow': f"Mañana · {tomorrow_weekday_name} {tomorrow_dt.strftime('%d/%m/%Y')}",
|
||||
'tomorrow_short': f"{tomorrow_weekday_name} {tomorrow_dt.strftime('%d/%m')}",
|
||||
'tomorrow_full': f"{tomorrow_weekday_name}, {tomorrow_dt.day} de {tomorrow_month_name} de {tomorrow_dt.year}",
|
||||
'week': f"Semana del {week_start.strftime('%d/%m')} al {week_end.strftime('%d/%m/%Y')}",
|
||||
'week_full': f"Semana del {week_start.strftime('%d/%m/%Y')} al {week_end.strftime('%d/%m/%Y')}",
|
||||
'month': f"Mes de {month_name} {today_dt.year} ({month_start.strftime('%d/%m')} al {month_end.strftime('%d/%m/%Y')})",
|
||||
@@ -178,6 +187,12 @@ def get_stats():
|
||||
}
|
||||
|
||||
# Reservas por período
|
||||
tomorrow_reservations_q = Reservation.query.filter(
|
||||
Reservation.start_time >= tomorrow_start,
|
||||
Reservation.start_time <= tomorrow_end
|
||||
).order_by(Reservation.start_time.asc()).all()
|
||||
tomorrow_schedule_list = [serialize_reservation(r) for r in tomorrow_reservations_q]
|
||||
|
||||
week_reservations_q = Reservation.query.filter(
|
||||
Reservation.start_time >= week_start,
|
||||
Reservation.start_time <= week_end
|
||||
@@ -195,6 +210,11 @@ def get_stats():
|
||||
if r.classroom_id:
|
||||
res_map_classroom_today.setdefault(r.classroom_id, []).append(r)
|
||||
|
||||
res_map_classroom_tomorrow = {}
|
||||
for r in tomorrow_reservations_q:
|
||||
if r.classroom_id:
|
||||
res_map_classroom_tomorrow.setdefault(r.classroom_id, []).append(r)
|
||||
|
||||
res_map_classroom_week = {}
|
||||
for r in week_reservations_q:
|
||||
if r.classroom_id:
|
||||
@@ -211,6 +231,11 @@ def get_stats():
|
||||
if r.commission_id:
|
||||
res_map_comm_today.setdefault(r.commission_id, []).append(r)
|
||||
|
||||
res_map_comm_tomorrow = {}
|
||||
for r in tomorrow_reservations_q:
|
||||
if r.commission_id:
|
||||
res_map_comm_tomorrow.setdefault(r.commission_id, []).append(r)
|
||||
|
||||
res_map_comm_week = {}
|
||||
for r in week_reservations_q:
|
||||
if r.commission_id:
|
||||
@@ -273,10 +298,13 @@ def get_stats():
|
||||
# 1. Hoy
|
||||
classrooms_assigned_today = [build_classroom_item(c, res_map_classroom_today[c.id]) for c in physical_classrooms_list if c.id in res_map_classroom_today]
|
||||
classrooms_unassigned_today = [build_classroom_item(c, []) for c in physical_classrooms_list if c.id not in res_map_classroom_today]
|
||||
# 2. Semana
|
||||
# 2. Mañana
|
||||
classrooms_assigned_tomorrow = [build_classroom_item(c, res_map_classroom_tomorrow[c.id]) for c in physical_classrooms_list if c.id in res_map_classroom_tomorrow]
|
||||
classrooms_unassigned_tomorrow = [build_classroom_item(c, []) for c in physical_classrooms_list if c.id not in res_map_classroom_tomorrow]
|
||||
# 3. Semana
|
||||
classrooms_assigned_week = [build_classroom_item(c, res_map_classroom_week[c.id]) for c in physical_classrooms_list if c.id in res_map_classroom_week]
|
||||
classrooms_unassigned_week = [build_classroom_item(c, []) for c in physical_classrooms_list if c.id not in res_map_classroom_week]
|
||||
# 3. Mes
|
||||
# 4. Mes
|
||||
classrooms_assigned_month = [build_classroom_item(c, res_map_classroom_month[c.id]) for c in physical_classrooms_list if c.id in res_map_classroom_month]
|
||||
classrooms_unassigned_month = [build_classroom_item(c, []) for c in physical_classrooms_list if c.id not in res_map_classroom_month]
|
||||
|
||||
@@ -284,10 +312,13 @@ def get_stats():
|
||||
# 1. Hoy
|
||||
commissions_assigned_today = [build_comm_item(comm, res_map_comm_today[comm.id]) for comm in all_active_commissions if comm.id in res_map_comm_today]
|
||||
commissions_unassigned_today = [build_comm_item(comm, []) for comm in all_active_commissions if comm.id not in res_map_comm_today]
|
||||
# 2. Semana
|
||||
# 2. Mañana
|
||||
commissions_assigned_tomorrow = [build_comm_item(comm, res_map_comm_tomorrow[comm.id]) for comm in all_active_commissions if comm.id in res_map_comm_tomorrow]
|
||||
commissions_unassigned_tomorrow = [build_comm_item(comm, []) for comm in all_active_commissions if comm.id not in res_map_comm_tomorrow]
|
||||
# 3. Semana
|
||||
commissions_assigned_week = [build_comm_item(comm, res_map_comm_week[comm.id]) for comm in all_active_commissions if comm.id in res_map_comm_week]
|
||||
commissions_unassigned_week = [build_comm_item(comm, []) for comm in all_active_commissions if comm.id not in res_map_comm_week]
|
||||
# 3. Mes
|
||||
# 4. Mes
|
||||
commissions_assigned_month = [build_comm_item(comm, res_map_comm_month[comm.id]) for comm in all_active_commissions if comm.id in res_map_comm_month]
|
||||
commissions_unassigned_month = [build_comm_item(comm, []) for comm in all_active_commissions if comm.id not in res_map_comm_month]
|
||||
|
||||
@@ -310,6 +341,7 @@ def get_stats():
|
||||
for comm in all_active_commissions:
|
||||
if comm.id in comm_ids_virtual:
|
||||
res_today = res_map_comm_today.get(comm.id, [])
|
||||
res_tomorrow = res_map_comm_tomorrow.get(comm.id, [])
|
||||
res_week = res_map_comm_week.get(comm.id, [])
|
||||
res_month = res_map_comm_month.get(comm.id, [])
|
||||
v_link = comm.virtual_link or (res_today[0].virtual_link if res_today and res_today[0].virtual_link else '')
|
||||
@@ -331,10 +363,12 @@ def get_stats():
|
||||
'building': 'Campus Virtual',
|
||||
'floor': 'Remoto ∞',
|
||||
'today_classes': len(res_today),
|
||||
'tomorrow_classes': len(res_tomorrow),
|
||||
'week_classes': len(res_week),
|
||||
'month_classes': len(res_month),
|
||||
'res_count': len(res_month),
|
||||
'is_active_today': len(res_today) > 0,
|
||||
'is_active_tomorrow': len(res_tomorrow) > 0,
|
||||
'assigned_summary': f"{comm.subject.name if comm.subject else 'Clase Virtual'} ({comm.schedule or 'Remoto'})"
|
||||
})
|
||||
|
||||
@@ -355,8 +389,10 @@ def get_stats():
|
||||
|
||||
# Compatibilidad hacia atrás para vistas existentes
|
||||
available_classrooms_today = classrooms_unassigned_today
|
||||
available_classrooms_tomorrow = classrooms_unassigned_tomorrow
|
||||
available_classrooms_week = classrooms_unassigned_week
|
||||
available_classrooms_month = classrooms_unassigned_month
|
||||
unassigned_commissions_tomorrow = commissions_unassigned_tomorrow
|
||||
unassigned_commissions_week = commissions_unassigned_week
|
||||
unassigned_commissions_month = commissions_unassigned_month
|
||||
|
||||
@@ -386,6 +422,29 @@ def get_stats():
|
||||
'total': total_active_commissions
|
||||
}
|
||||
},
|
||||
'tomorrow': {
|
||||
'label': date_labels['tomorrow'],
|
||||
'date_short': date_labels['tomorrow_short'],
|
||||
'date_full': date_labels['tomorrow_full'],
|
||||
'classrooms': {
|
||||
'assigned': classrooms_assigned_tomorrow,
|
||||
'unassigned': classrooms_unassigned_tomorrow,
|
||||
'assigned_count': len(classrooms_assigned_tomorrow),
|
||||
'unassigned_count': len(classrooms_unassigned_tomorrow),
|
||||
'assigned_pct': round((len(classrooms_assigned_tomorrow) / max(1, total_physical_count)) * 100, 1),
|
||||
'unassigned_pct': round((len(classrooms_unassigned_tomorrow) / max(1, total_physical_count)) * 100, 1),
|
||||
'total': total_physical_count
|
||||
},
|
||||
'commissions': {
|
||||
'assigned': commissions_assigned_tomorrow,
|
||||
'unassigned': commissions_unassigned_tomorrow,
|
||||
'assigned_count': len(commissions_assigned_tomorrow),
|
||||
'unassigned_count': len(commissions_unassigned_tomorrow),
|
||||
'assigned_pct': round((len(commissions_assigned_tomorrow) / max(1, total_active_commissions)) * 100, 1),
|
||||
'unassigned_pct': round((len(commissions_unassigned_tomorrow) / max(1, total_active_commissions)) * 100, 1),
|
||||
'total': total_active_commissions
|
||||
}
|
||||
},
|
||||
'week': {
|
||||
'label': date_labels['week'],
|
||||
'date_short': date_labels['week'],
|
||||
@@ -503,12 +562,14 @@ def get_stats():
|
||||
'assigned_today_pct': assigned_today_pct,
|
||||
'unassigned_today_classrooms': unassigned_today_count,
|
||||
'unassigned_today_pct': unassigned_today_pct,
|
||||
'total_active_commissions': total_active_commissions
|
||||
'total_active_commissions': total_active_commissions,
|
||||
'tomorrow_reservations': len(tomorrow_reservations_q) if 'tomorrow_reservations_q' in locals() else 0
|
||||
},
|
||||
'audit_logs': audit_data,
|
||||
'monthly_data': monthly_data,
|
||||
'pending_reservations': pending_reservations,
|
||||
'today_schedule_list': today_schedule_list,
|
||||
'tomorrow_schedule_list': tomorrow_schedule_list if 'tomorrow_schedule_list' in locals() else [],
|
||||
'week_schedule_list': week_schedule_list,
|
||||
'upcoming_reservations': upcoming_reservations,
|
||||
'milestones': milestones,
|
||||
@@ -516,10 +577,12 @@ def get_stats():
|
||||
'show_role_banner': SystemSetting.get_value('dashboard_role_banner_enabled', 'true') in ['true', 'True', '1', True]
|
||||
},
|
||||
'bedelia': {
|
||||
'unassigned_commissions_tomorrow': unassigned_commissions_tomorrow if 'unassigned_commissions_tomorrow' in locals() else [],
|
||||
'unassigned_commissions_week': unassigned_commissions_week,
|
||||
'unassigned_commissions_month': unassigned_commissions_month,
|
||||
'unassigned_commissions_general': unassigned_commissions_general,
|
||||
'available_classrooms_today': available_classrooms_today,
|
||||
'available_classrooms_tomorrow': available_classrooms_tomorrow if 'available_classrooms_tomorrow' in locals() else [],
|
||||
'available_classrooms_week': available_classrooms_week,
|
||||
'available_classrooms_month': available_classrooms_month,
|
||||
'virtual_rooms': virtual_rooms_data,
|
||||
|
||||
@@ -7,7 +7,7 @@ OPENAPI_SPEC = {
|
||||
"info": {
|
||||
"title": "Edu-Space REST API",
|
||||
"description": "Enterprise Academic & Physical Space Management REST API with JWT Authentication and Role-Based Access Control.",
|
||||
"version": "3.4.3"
|
||||
"version": "3.4.4"
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="edu-space-admin",
|
||||
version="3.4.3",
|
||||
version="3.4.4",
|
||||
description="Administrative interface for Edu-Space Classroom Management System",
|
||||
author="Edu-Space Development Team",
|
||||
author_email="admin@edu-space.com",
|
||||
|
||||
Reference in New Issue
Block a user