fix(ai-chat): harden prompt security against injections, fix login methods detection & align desktop input dock (v3.8.43)
This commit is contained in:
+149
-128
@@ -8,19 +8,21 @@
|
||||
<div class="d-flex flex-wrap align-items-center justify-content-between gap-3 mb-4">
|
||||
<div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<span class="badge bg-warning-subtle text-warning-emphasis border border-warning-subtle rounded-pill px-3 py-1 fw-semibold">
|
||||
<span
|
||||
class="badge bg-warning-subtle text-warning-emphasis border border-warning-subtle rounded-pill px-3 py-1 fw-semibold">
|
||||
<i class="bi bi-tag-fill me-1"></i> Bedelía & Servicios
|
||||
</span>
|
||||
<span class="text-muted small">Módulo SDD-012</span>
|
||||
</div>
|
||||
<h1 class="h3 fw-bold mt-1 mb-0">Gestión de Convenios & Beneficios</h1>
|
||||
<p class="text-muted small mb-0">Administra las promociones comerciales, descuentos en cafeterías, librerías y beneficios para la comunidad UniCABA.</p>
|
||||
<p class="text-muted small mb-0">Administra las promociones comerciales, descuentos en cafeterías, librerías
|
||||
y beneficios para la comunidad UniCABA.</p>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<a href="/benefits" class="btn btn-outline-secondary btn-sm rounded-pill px-3">
|
||||
<i class="bi bi-eye me-1"></i> Ver Catálogo Público
|
||||
</a>
|
||||
<button type="button" class="btn btn-primary btn-sm rounded-pill px-3 shadow-sm" data-bs-toggle="modal" data-bs-target="#benefitModal" onclick="openCreateModal()">
|
||||
<button type="button" class="btn btn-primary btn-sm rounded-pill px-3 shadow-sm" data-bs-toggle="modal"
|
||||
data-bs-target="#benefitModal" onclick="openCreateModal()">
|
||||
<i class="bi bi-plus-lg me-1"></i> Nuevo Convenio
|
||||
</button>
|
||||
</div>
|
||||
@@ -52,7 +54,7 @@
|
||||
<h3 class="fw-bold mb-0 text-success mt-1" id="activeCount">
|
||||
{% set active_count = 0 %}
|
||||
{% for b in benefits %}
|
||||
{% if b.is_active %}{% set active_count = active_count + 1 %}{% endif %}
|
||||
{% if b.is_active %}{% set active_count = active_count + 1 %}{% endif %}
|
||||
{% endfor %}
|
||||
{{ active_count }}
|
||||
</h3>
|
||||
@@ -93,10 +95,12 @@
|
||||
|
||||
<!-- Tabla Principal de Convenios -->
|
||||
<div class="card border-0 shadow-sm rounded-4 overflow-hidden">
|
||||
<div class="card-header bg-body border-0 py-3 px-4 d-flex flex-wrap align-items-center justify-content-between gap-3">
|
||||
<div
|
||||
class="card-header bg-body border-0 py-3 px-4 d-flex flex-wrap align-items-center justify-content-between gap-3">
|
||||
<h5 class="fw-bold mb-0">Nómina de Convenios Registrados</h5>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<input type="text" id="tableFilter" class="form-control form-control-sm rounded-pill px-3" placeholder="Filtrar por comercio o título..." style="min-width: 240px;">
|
||||
<input type="text" id="tableFilter" class="form-control form-control-sm rounded-pill px-3"
|
||||
placeholder="Filtrar por comercio o título..." style="min-width: 240px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
@@ -116,117 +120,124 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if benefits and benefits | length > 0 %}
|
||||
{% for b in benefits %}
|
||||
<tr id="benefit-row-{{ b.id }}" data-search="{{ b.title | lower }} {{ b.partner_name | lower }} {{ b.category | lower }}">
|
||||
<td class="ps-4">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="rounded-3 p-2 bg-primary-subtle text-primary d-flex align-items-center justify-content-center" style="width: 42px; height: 42px;">
|
||||
{% if b.category == 'GASTRONOMIA' %}
|
||||
<i class="bi bi-cup-hot fs-5"></i>
|
||||
{% elif b.category == 'LIBRERIA' %}
|
||||
<i class="bi bi-book fs-5"></i>
|
||||
{% elif b.category == 'TECNOLOGIA' %}
|
||||
<i class="bi bi-laptop fs-5"></i>
|
||||
{% elif b.category == 'SALUD_DEPORTE' %}
|
||||
<i class="bi bi-heart-pulse fs-5"></i>
|
||||
{% else %}
|
||||
<i class="bi bi-tag fs-5"></i>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<div class="fw-bold text-dark">{{ b.title }}</div>
|
||||
<div class="small text-muted"><i class="bi bi-shop me-1"></i>{{ b.partner_name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-secondary-subtle text-secondary-emphasis rounded-pill px-2 py-1 small">
|
||||
{{ b.category }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle rounded-pill px-2 py-1 fw-bold">
|
||||
{{ b.discount_label }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="small text-muted">
|
||||
<i class="bi bi-geo-alt me-1"></i>{{ b.building_name or 'Todas las Sedes' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if b.target_roles == 'ALL' %}
|
||||
<span class="badge bg-info-subtle text-info rounded-pill px-2">Todos</span>
|
||||
{% elif 'ALUMNO' in b.target_roles and 'DOCENTE' in b.target_roles %}
|
||||
<span class="badge bg-primary-subtle text-primary rounded-pill px-2">Alumnos & Docentes</span>
|
||||
{% elif 'ALUMNO' in b.target_roles %}
|
||||
<span class="badge bg-success-subtle text-success rounded-pill px-2">Solo Alumnos</span>
|
||||
{% elif 'DOCENTE' in b.target_roles %}
|
||||
<span class="badge bg-warning-subtle text-warning-emphasis rounded-pill px-2">Solo Docentes</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary-subtle text-secondary rounded-pill px-2">{{ b.target_roles }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">
|
||||
<div><i class="bi bi-calendar-check me-1 text-success"></i>Desde: {{ b.valid_from }}</div>
|
||||
{% if b.valid_until %}
|
||||
<div><i class="bi bi-calendar-x me-1 text-danger"></i>Hasta: {{ b.valid_until }}</div>
|
||||
{% for b in benefits %}
|
||||
<tr id="benefit-row-{{ b.id }}"
|
||||
data-search="{{ b.title | lower }} {{ b.partner_name | lower }} {{ b.category | lower }}">
|
||||
<td class="ps-4">
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
<div class="rounded-3 p-2 bg-primary-subtle text-primary d-flex align-items-center justify-content-center"
|
||||
style="width: 42px; height: 42px;">
|
||||
{% if b.category == 'GASTRONOMIA' %}
|
||||
<i class="bi bi-cup-hot fs-5"></i>
|
||||
{% elif b.category == 'LIBRERIA' %}
|
||||
<i class="bi bi-book fs-5"></i>
|
||||
{% elif b.category == 'TECNOLOGIA' %}
|
||||
<i class="bi bi-laptop fs-5"></i>
|
||||
{% elif b.category == 'SALUD_DEPORTE' %}
|
||||
<i class="bi bi-heart-pulse fs-5"></i>
|
||||
{% else %}
|
||||
<div class="text-muted"><i class="bi bi-infinity me-1"></i>Indefinido</div>
|
||||
<i class="bi bi-tag fs-5"></i>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{% if b.coupon_code %}
|
||||
<code class="px-2 py-1 bg-light rounded text-primary fw-bold small border">{{ b.coupon_code }}</code>
|
||||
<div>
|
||||
<div class="fw-bold text-dark">{{ b.title }}</div>
|
||||
<div class="small text-muted"><i class="bi bi-shop me-1"></i>{{ b.partner_name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
class="badge bg-secondary-subtle text-secondary-emphasis rounded-pill px-2 py-1 small">
|
||||
{{ b.category }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
class="badge bg-danger-subtle text-danger border border-danger-subtle rounded-pill px-2 py-1 fw-bold">
|
||||
{{ b.discount_label }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="small text-muted">
|
||||
<i class="bi bi-geo-alt me-1"></i>{{ b.building_name or 'Todas las Sedes' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if b.target_roles == 'ALL' %}
|
||||
<span class="badge bg-info-subtle text-info rounded-pill px-2">Todos</span>
|
||||
{% elif 'ALUMNO' in b.target_roles and 'DOCENTE' in b.target_roles %}
|
||||
<span class="badge bg-primary-subtle text-primary rounded-pill px-2">Alumnos &
|
||||
Docentes</span>
|
||||
{% elif 'ALUMNO' in b.target_roles %}
|
||||
<span class="badge bg-success-subtle text-success rounded-pill px-2">Solo Alumnos</span>
|
||||
{% elif 'DOCENTE' in b.target_roles %}
|
||||
<span class="badge bg-warning-subtle text-warning-emphasis rounded-pill px-2">Solo
|
||||
Docentes</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary-subtle text-secondary rounded-pill px-2">{{ b.target_roles
|
||||
}}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="small">
|
||||
<div><i class="bi bi-calendar-check me-1 text-success"></i>Desde: {{ b.valid_from }}
|
||||
</div>
|
||||
{% if b.valid_until %}
|
||||
<div><i class="bi bi-calendar-x me-1 text-danger"></i>Hasta: {{ b.valid_until }}</div>
|
||||
{% else %}
|
||||
<span class="text-muted small">Credencial</span>
|
||||
<div class="text-muted"><i class="bi bi-infinity me-1"></i>Indefinido</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="form-check form-switch d-inline-block">
|
||||
<input class="form-check-input switch-toggle-status" type="checkbox" role="switch" id="switch-{{ b.id }}" data-id="{{ b.id }}" {% if b.is_active %}checked{% endif %}>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end pe-4">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button type="button" class="btn btn-outline-secondary rounded-start-pill btn-edit-benefit" title="Editar"
|
||||
data-id="{{ b.id }}"
|
||||
data-title="{{ b.title }}"
|
||||
data-partner="{{ b.partner_name }}"
|
||||
data-category="{{ b.category }}"
|
||||
data-discount="{{ b.discount_label }}"
|
||||
data-coupon="{{ b.coupon_code or '' }}"
|
||||
data-building="{{ b.building_id or '' }}"
|
||||
data-roles="{{ b.target_roles or 'ALL' }}"
|
||||
data-from="{{ b.valid_from or '' }}"
|
||||
data-until="{{ b.valid_until or '' }}"
|
||||
data-desc="{{ b.description or '' }}"
|
||||
data-terms="{{ b.terms_conditions or '' }}"
|
||||
data-active="{{ '1' if b.is_active else '0' }}">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline-danger rounded-end-pill btn-delete-benefit" title="Eliminar"
|
||||
data-id="{{ b.id }}"
|
||||
data-title="{{ b.title }}">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="9" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-tags display-4 d-block mb-3 text-secondary opacity-50"></i>
|
||||
<h5>No hay convenios cargados aún</h5>
|
||||
<p class="small text-muted mb-3">Comienza creando promociones de cafetería, librerías y comercios para los alumnos y docentes.</p>
|
||||
<button type="button" class="btn btn-primary btn-sm rounded-pill px-4" data-bs-toggle="modal" data-bs-target="#benefitModal" onclick="openCreateModal()">
|
||||
<i class="bi bi-plus-lg me-1"></i> Crear Primer Convenio
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{% if b.coupon_code %}
|
||||
<code
|
||||
class="px-2 py-1 bg-light rounded text-primary fw-bold small border">{{ b.coupon_code }}</code>
|
||||
{% else %}
|
||||
<span class="text-muted small">Credencial</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="form-check form-switch d-inline-block">
|
||||
<input class="form-check-input switch-toggle-status" type="checkbox" role="switch"
|
||||
id="switch-{{ b.id }}" data-id="{{ b.id }}" {% if b.is_active %}checked{% endif %}>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-end pe-4">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button type="button"
|
||||
class="btn btn-outline-secondary rounded-start-pill btn-edit-benefit" title="Editar"
|
||||
data-id="{{ b.id }}" data-title="{{ b.title }}" data-partner="{{ b.partner_name }}"
|
||||
data-category="{{ b.category }}" data-discount="{{ b.discount_label }}"
|
||||
data-coupon="{{ b.coupon_code or '' }}" data-building="{{ b.building_id or '' }}"
|
||||
data-roles="{{ b.target_roles or 'ALL' }}" data-from="{{ b.valid_from or '' }}"
|
||||
data-until="{{ b.valid_until or '' }}" data-desc="{{ b.description or '' }}"
|
||||
data-terms="{{ b.terms_conditions or '' }}"
|
||||
data-active="{{ '1' if b.is_active else '0' }}">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<button type="button" class="btn btn-outline-danger rounded-end-pill btn-delete-benefit"
|
||||
title="Eliminar" data-id="{{ b.id }}" data-title="{{ b.title }}">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="9" class="text-center py-5 text-muted">
|
||||
<i class="bi bi-tags display-4 d-block mb-3 text-secondary opacity-50"></i>
|
||||
<h5>No hay convenios cargados aún</h5>
|
||||
<p class="small text-muted mb-3">Comienza creando promociones de cafetería, librerías y
|
||||
comercios para los alumnos y docentes.</p>
|
||||
<button type="button" class="btn btn-primary btn-sm rounded-pill px-4"
|
||||
data-bs-toggle="modal" data-bs-target="#benefitModal" onclick="openCreateModal()">
|
||||
<i class="bi bi-plus-lg me-1"></i> Crear Primer Convenio
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -243,19 +254,22 @@
|
||||
<h5 class="modal-title fw-bold" id="benefitModalLabel">
|
||||
<i class="bi bi-tag-fill me-2"></i> Nuevo Convenio Comercial
|
||||
</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<input type="hidden" id="benefitId" name="benefitId">
|
||||
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-7">
|
||||
<label class="form-label small fw-bold">Título de la Promoción *</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required placeholder="Ej: 20% en Cafetería La Estación">
|
||||
<input type="text" class="form-control" id="title" name="title" required
|
||||
placeholder="Ej: 20% en Cafetería La Estación">
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<label class="form-label small fw-bold">Comercio / Entidad *</label>
|
||||
<input type="text" class="form-control" id="partner_name" name="partner_name" required placeholder="Ej: Café Martínez Central">
|
||||
<input type="text" class="form-control" id="partner_name" name="partner_name" required
|
||||
placeholder="Ej: Café Martínez Central">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
@@ -272,11 +286,13 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-bold">Etiqueta de Descuento *</label>
|
||||
<input type="text" class="form-control" id="discount_label" name="discount_label" required placeholder="Ej: 20% OFF / 2x1">
|
||||
<input type="text" class="form-control" id="discount_label" name="discount_label" required
|
||||
placeholder="Ej: 20% OFF / 2x1">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small fw-bold">Código de Cupón (Opcional)</label>
|
||||
<input type="text" class="form-control" id="coupon_code" name="coupon_code" placeholder="Ej: UNICABA-20">
|
||||
<input type="text" class="form-control" id="coupon_code" name="coupon_code"
|
||||
placeholder="Ej: UNICABA-20">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
@@ -309,24 +325,29 @@
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label small fw-bold">Descripción del Beneficio</label>
|
||||
<textarea class="form-control" id="description" name="description" rows="2" placeholder="Detalles de cómo aprovechar el beneficio en el local..."></textarea>
|
||||
<textarea class="form-control" id="description" name="description" rows="2"
|
||||
placeholder="Detalles de cómo aprovechar el beneficio en el local..."></textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<label class="form-label small fw-bold">Términos & Condiciones</label>
|
||||
<textarea class="form-control" id="terms_conditions" name="terms_conditions" rows="2" placeholder="Válido de lunes a viernes con credencial universitaria vigente..."></textarea>
|
||||
<textarea class="form-control" id="terms_conditions" name="terms_conditions" rows="2"
|
||||
placeholder="Válido de lunes a viernes con credencial universitaria vigente..."></textarea>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
<div class="form-check form-switch mt-2">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="is_active" name="is_active" checked>
|
||||
<label class="form-check-label fw-semibold" for="is_active">Publicar inmediatamente en el catálogo de alumnos y docentes</label>
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="is_active"
|
||||
name="is_active" checked>
|
||||
<label class="form-check-label fw-semibold" for="is_active">Publicar inmediatamente en
|
||||
el catálogo de alumnos y docentes</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light py-3 px-4">
|
||||
<button type="button" class="btn btn-outline-secondary rounded-pill px-4" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="button" class="btn btn-outline-secondary rounded-pill px-4"
|
||||
data-bs-dismiss="modal">Cancelar</button>
|
||||
<button type="submit" class="btn btn-primary rounded-pill px-4" id="submitBtn">
|
||||
<i class="bi bi-check-lg me-1"></i> Guardar Convenio
|
||||
</button>
|
||||
@@ -338,7 +359,7 @@
|
||||
|
||||
<script>
|
||||
// Filtro en tiempo real de la tabla
|
||||
document.getElementById('tableFilter').addEventListener('input', function(e) {
|
||||
document.getElementById('tableFilter').addEventListener('input', function (e) {
|
||||
const val = e.target.value.toLowerCase().trim();
|
||||
const rows = document.querySelectorAll('#benefitsTable tbody tr[data-search]');
|
||||
rows.forEach(r => {
|
||||
@@ -347,8 +368,8 @@
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('click', function(e) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.addEventListener('click', function (e) {
|
||||
const editBtn = e.target.closest('.btn-edit-benefit');
|
||||
if (editBtn) {
|
||||
openEditModal({
|
||||
@@ -376,7 +397,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('change', function(e) {
|
||||
document.addEventListener('change', function (e) {
|
||||
const sw = e.target.closest('.switch-toggle-status');
|
||||
if (sw) {
|
||||
toggleStatus(sw.getAttribute('data-id'));
|
||||
@@ -452,4 +473,4 @@
|
||||
setTimeout(() => { container.innerHTML = ''; }, 4000);
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user