feat(benefits-reception): add institutional benefits, QR digital card & reception access control (SDD-012 v3.8.39)
This commit is contained in:
@@ -18,6 +18,7 @@ from app.models.reservation import Reservation
|
||||
from app.models.enrollment import StudentEnrollment
|
||||
from app.models.milestone import AcademicMilestone, MilestoneType
|
||||
from app.models.grade import MilestoneGrade
|
||||
from app.models.institutional_benefit import InstitutionalBenefit
|
||||
from app import db
|
||||
from app.models.user import User
|
||||
from app.services.gradebook_service import GradebookService
|
||||
@@ -621,6 +622,39 @@ class LiveContextService:
|
||||
for rm in matched_rooms:
|
||||
cap = rm.capacity_display
|
||||
lines.append(f"• Aula {rm.code_display} (Piso: {rm.floor_display}, Capacidad: {cap})")
|
||||
|
||||
# E. Búsqueda de Convenios y Beneficios Institucionales
|
||||
benefit_keywords = [
|
||||
'convenio', 'convenios', 'beneficio', 'beneficios', 'descuento', 'descuentos',
|
||||
'promocion', 'promociones', 'promo', 'cafeteria', 'cafe', 'comida', 'almuerzo',
|
||||
'libreria', 'fotocopia', 'deporte', 'gimnasio', 'salud', 'cupon'
|
||||
]
|
||||
if any(bk in q_lower for bk in benefit_keywords):
|
||||
from datetime import date
|
||||
today_b = date.today()
|
||||
active_b = (
|
||||
InstitutionalBenefit.query
|
||||
.filter(
|
||||
InstitutionalBenefit.is_active.is_(True),
|
||||
InstitutionalBenefit.valid_from <= today_b,
|
||||
or_(
|
||||
InstitutionalBenefit.valid_until.is_(None),
|
||||
InstitutionalBenefit.valid_until >= today_b
|
||||
)
|
||||
)
|
||||
.order_by(InstitutionalBenefit.title.asc())
|
||||
.limit(8)
|
||||
.all()
|
||||
)
|
||||
matching_b = [b for b in active_b if b.applies_to_role(role)]
|
||||
if matching_b:
|
||||
lines.append("\nCONVENIOS Y BENEFICIOS INSTITUCIONALES ACTIVOS:")
|
||||
for ben in matching_b:
|
||||
bld_str = f"en {ben.building.name}" if ben.building else "en Todas las Sedes"
|
||||
coupon_str = f" | Código Cupón: {ben.coupon_code}" if ben.coupon_code else ""
|
||||
lines.append(f"• {ben.title}: {ben.discount_label} en {ben.partner_name} ({ben.category} {bld_str}){coupon_str}. {ben.description or ''}")
|
||||
else:
|
||||
lines.append("\nCONVENIOS Y BENEFICIOS: No se encontraron promociones activas registradas para la consulta.")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user