Merge feat/ui-base: tokens, componentes y estructura común del rediseño CHM (Fase 1a)

This commit is contained in:
Fernando Davila committed 2026-10-09 11:20:21 -06:00
commit ca980a0fb6
17 files changed
+1413 -683

No files matched your search

+835 -660
View File
File diff suppressed because it is too large. Load diff
+10
View File
@@ -0,0 +1,10 @@
Fuentes self-hosted de collina-pld (sin CDN en tiempo de ejecución).
Origen: paquetes npm @fontsource/ibm-plex-sans, @fontsource/ibm-plex-mono y @fontsource/manrope,
versión 5.3.0, descargados de cdn.jsdelivr.net (solo los .woff2; npm no entra al proyecto).
Subconjunto "latin": U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD.
IBM Plex Sans 400/500/600 e IBM Plex Mono 400/500: toda la app.
Manrope 600/700/800: solo la pantalla de acceso.
Las @font-face viven en app/static/app.css. Licencia: SIL Open Font License 1.1 (LICENCIA-*.txt).
@@ -0,0 +1,93 @@
Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ThinItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLight.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-ExtraLightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Light.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-LightItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Regular.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Italic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Medium.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-MediumItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-SemiBoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-Bold.ttf: Copyright 2017 IBM Corp. All rights reserved. IBMPlexMono-BoldItalic.ttf: Copyright 2017 IBM Corp. All rights reserved.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
Copyright 2019 IBM Corp. All rights reserved. IBMPlexSans-Italic[wdth,wght].ttf: Copyright 2019 IBM Corp. All rights reserved.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
+93
View File
@@ -0,0 +1,93 @@
Copyright 2019 The Manrope Project Authors (https://github.com/sharanda/manrope)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+41
View File
@@ -0,0 +1,41 @@
{#- Íconos de trazo (sprite SVG). Un solo color: heredan currentColor del texto que los rodea.
{% from "_componentes/iconos.html" import icono %}
{{ icono("alertas") }} → <svg class="icono" aria-hidden="true"><use href="#i-alertas"/></svg>
{{ icono("chevron", "icono--14 icono--tenue") }} clases extra (tamaño, opacidad)
Disponibles: home, cartera, expediente, beneficiario, screening, riesgo, creditos, alertas,
evidencia, laboratorio, check, chevron, chevron-left, lock, logout, plus, search, menu.
Son decorativos (aria-hidden): el texto del enlace o un aria-label nombran la acción.
base.html llama sprite() una vez al inicio del <body>; ninguna otra plantilla lo hace.
Sin <nav> aquí: tests/test_auth.py corta la barra lateral desde el primer <nav class="nav">.
-#}
{%- macro icono(nombre, clase="") -%}
<svg class="icono{{ ' ' ~ clase if clase }}" aria-hidden="true"><use href="#i-{{ nombre }}"/></svg>
{%- endmacro -%}
{%- macro sprite() -%}
<svg class="sprite-iconos" aria-hidden="true" focusable="false">
<symbol id="i-home" viewBox="0 0 24 24"><path d="M3 11l9-7 9 7v9a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z"/></symbol>
<symbol id="i-cartera" viewBox="0 0 24 24"><rect x="3" y="7" width="18" height="13" rx="2"/><path d="M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><path d="M3 12h18"/></symbol>
<symbol id="i-expediente" viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></symbol>
<symbol id="i-beneficiario" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.5"/><path d="M2.5 20a6.5 6.5 0 0 1 13 0"/><path d="M16 4.5a3.5 3.5 0 0 1 0 7"/><path d="M18 14.5a5.5 5.5 0 0 1 3.5 5.5"/></symbol>
<symbol id="i-screening" viewBox="0 0 24 24"><circle cx="11" cy="11" r="6.5"/><path d="M16 16l5 5"/></symbol>
<symbol id="i-riesgo" viewBox="0 0 24 24"><path d="M4 16a8 8 0 1 1 16 0"/><path d="M12 16l3.5-5"/><circle cx="12" cy="16" r="1.2"/></symbol>
<symbol id="i-creditos" viewBox="0 0 24 24"><rect x="2.5" y="6" width="19" height="12" rx="2"/><path d="M2.5 10h19"/><path d="M6 14.5h4"/></symbol>
<symbol id="i-alertas" viewBox="0 0 24 24"><path d="M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15z"/><path d="M10 21a2 2 0 0 0 4 0"/></symbol>
<symbol id="i-evidencia" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="4" rx="1"/><path d="M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8"/><path d="M10 13h4"/></symbol>
<symbol id="i-laboratorio" viewBox="0 0 24 24"><path d="M9.5 3h5"/><path d="M10 3v6l-5.5 9.5A1.5 1.5 0 0 0 5.8 21h12.4a1.5 1.5 0 0 0 1.3-2.5L14 9V3"/><path d="M7.5 15h9"/></symbol>
<symbol id="i-check" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></symbol>
<symbol id="i-chevron" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></symbol>
<symbol id="i-chevron-left" viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></symbol>
<symbol id="i-lock" viewBox="0 0 24 24"><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></symbol>
<symbol id="i-logout" viewBox="0 0 24 24"><path d="M10 17l5-5-5-5"/><path d="M15 12H3"/><path d="M13 4h5a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-5"/></symbol>
<symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
<symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></symbol>
<symbol id="i-menu" viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h16"/></symbol>
</svg>
{%- endmacro -%}
+62 -23
View File
@@ -1,14 +1,20 @@
{#- Layout común. Toda pantalla lo extiende y llena `titulo` y `contenido`:
{% extends "base.html" %}
{% set ancho = "amplio" %} opcional: holgado | amplio | extra (ancho del contenido)
{% block titulo %}Alertas{% endblock %}
{% block contenido %}...{% endblock %}
Se sirve con `render()` de app/routers, que aporta usuario, tenant y navegación. Con sesión
pinta la barra lateral y el encabezado; sin sesión (login), solo el contenido centrado.
Bloques opcionales: `cabecera` (dentro de <head>) y `scripts` (al final del <body>).
pinta la barra lateral y el encabezado; sin sesión (acceso) pinta solo el contenido, a pantalla
completa. Bloques opcionales: `cabecera` (dentro de <head>) y `scripts` (al final del <body>).
Contratos que leen los tests (tests/test_auth.py y otros): un solo <nav class="nav"> y ningún
<nav> antes que él; enlaces con class="nav__enlace" o "nav__enlace es-activo" exactos (Inicio y
Cartera se distinguen con data-principal); pasos no disponibles con aria-disabled="true";
el encabezado pinta tenant.actividad_vulnerable tal cual; aquí no hay enlaces a /clientes/.
-#}
{%- from "_componentes/badges.html" import badge -%}
{%- from "_componentes/iconos.html" import icono, sprite -%}
<!doctype html>
<html lang="es-MX">
<head>
@@ -16,26 +22,50 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<title>{% block titulo %}Inicio{% endblock %} · PLD/FT</title>
<link rel="preload" href="/static/fuentes/ibm-plex-sans-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="/static/app.css?v={{ version }}">
{%- block cabecera %}{% endblock %}
</head>
<body>
<div class="app{% if not usuario %} app--publica{% endif %}">
{%- if usuario %}
{{ sprite() }}
{%- if usuario %}
{#- Ícono por ruta de la navegación y rol legible (D12). -#}
{%- set nav_iconos = {
"/inicio": "home", "/cartera": "cartera", "/expediente": "expediente",
"/beneficiario-controlador": "beneficiario", "/screening": "screening", "/riesgo": "riesgo",
"/creditos": "creditos", "/alertas": "alertas", "/evidencia": "evidencia", "/laboratorio": "laboratorio",
} %}
{%- set nav_roles = {"oficial": "Oficial de cumplimiento", "analista": "Analista", "auditor": "Auditor"} %}
{#- Pantallas cuya ruta no cuelga de la de su paso: se marcan con el paso al que pertenecen. -#}
{%- set nav_alias = [("/operaciones", "/creditos"), ("/clientes", "/expediente"), ("/casos", "/alertas"), ("/auditoria", "/evidencia")] %}
{%- set nav = namespace(ruta_activa=none, actual=request.url.path) %}
{%- if not (navegacion | selectattr("activo") | list) %}
{%- if nav.actual.startswith("/clientes/") and nav.actual.endswith("/beneficiario") %}
{%- set nav.ruta_activa = "/beneficiario-controlador" %}
{%- else %}
{%- for prefijo, destino in nav_alias %}
{%- if nav.ruta_activa is none and (nav.actual == prefijo or nav.actual.startswith(prefijo ~ "/")) %}
{%- set nav.ruta_activa = destino %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
<div class="app">
<aside class="lateral" id="lateral">
<a class="marca" href="/inicio">
<span class="marca__sigla">PLD</span>
<span class="marca__texto">Prevención de lavado<small>CHM Compliance</small></span>
<a class="marca" href="/inicio" aria-label="Inicio">
<img class="logo" src="/static/img/chm-logo.png" width="480" height="205" alt="CHM Compliance">
<span class="marca__ceja">Prevención de lavado</span>
</a>
<nav class="nav" aria-label="Navegación principal">
{%- for entrada in navegacion %}
{%- if entrada.paso == 1 %}
<p class="nav__seccion">Recorrido</p>
<p class="nav__seccion">Módulos</p>
{%- endif %}
{%- set activo = entrada.activo or entrada.ruta == nav.ruta_activa %}
{%- if entrada.disponible %}
<a class="nav__enlace{% if entrada.activo %} es-activo{% endif %}" href="{{ entrada.ruta }}"
{%- if entrada.activo %} aria-current="page"{% endif %}>
<span class="nav__paso">{{ entrada.paso if entrada.paso else "" }}</span>
<a class="nav__enlace{% if activo %} es-activo{% endif %}" href="{{ entrada.ruta }}"
{%- if activo %} aria-current="page"{% endif %}{% if entrada.paso is none %} data-principal{% endif %}>
{{- icono(nav_iconos.get(entrada.ruta, "chevron")) -}}
<span class="nav__titulo">{{ entrada.titulo }}</span>
{%- if entrada.contador %}
<span class="nav__contador" title="Pendientes">{{ entrada.contador }}</span>
@@ -44,41 +74,50 @@
{%- else %}
<span class="nav__enlace es-deshabilitado" aria-disabled="true"
title="Disponible en la fase {{ entrada.fase }}">
<span class="nav__paso">{{ entrada.paso if entrada.paso else "" }}</span>
{{- icono(nav_iconos.get(entrada.ruta, "chevron")) -}}
<span class="nav__titulo">{{ entrada.titulo }}</span>
<span class="nav__fase">fase {{ entrada.fase }}</span>
{{- icono("lock", "nav__candado") -}}
</span>
{%- endif %}
{%- endfor %}
</nav>
<p class="lateral__pie">v{{ version }}</p>
</aside>
{%- endif %}
<div class="principal">
{%- if usuario %}
<header class="encabezado">
<button class="encabezado__menu" type="button" data-alternar="#lateral"
aria-controls="lateral" aria-label="Mostrar u ocultar la navegación">☰</button>
<button class="boton boton--icono encabezado__menu" type="button" data-alternar="#lateral"
aria-controls="lateral" aria-expanded="false" aria-label="Mostrar u ocultar la navegación">
{{- icono("menu", "icono--16") -}}
</button>
<div class="encabezado__tenant">
<strong>{{ tenant.nombre }}</strong>
<span>{{ tenant.regimen }} · {{ tenant.actividad_vulnerable }}</span>
</div>
<div class="encabezado__usuario">
<span class="encabezado__nombre">{{ usuario.usuario }}</span>
{{ badge(usuario.rol, "acento") }}
<div class="usuario">
<span class="avatar" aria-hidden="true">{{ usuario.usuario[:1] | upper }}</span>
<span class="usuario__textos">
<span class="usuario__nombre">{{ usuario.usuario }}</span>
<span class="usuario__rol">{{ nav_roles.get(usuario.rol, usuario.rol) }}</span>
</span>
</div>
<form method="post" action="/logout">
<button class="boton boton--discreto" type="submit">Salir</button>
<button class="boton boton--mediano" type="submit">{{ icono("logout", "icono--16") }}<span>Salir</span></button>
</form>
</div>
</header>
{%- endif %}
<main class="contenido" id="contenido">
<main class="contenido{% if ancho is defined %} contenido--{{ ancho }}{% endif %}" id="contenido">
{%- else %}
<main id="contenido">
{%- endif %}
{%- block contenido %}{% endblock %}
</main>
{%- if usuario %}
</div>
</div>
{%- endif %}
<div class="toasts" id="toasts" aria-live="polite"></div>
<script src="/static/app.js?v={{ version }}" defer></script>
+186
View File
@@ -0,0 +1,186 @@
"""Humo del rediseño: con el usuario demo, cada pantalla GET de la app responde 200 y pinta la
estructura común (barra lateral, sprite de íconos, hoja de estilos).
Una sola base para todas las rutas, porque importar el fixture es lo caro: esquema con la sal de
la carga incremental, evaluación y reglas, identidades sintéticas, listas, casos plantados, matriz
v1, una carga incremental confirmada y un caso. Screening entra aunque su plantilla no se
rediseña: tiene que seguir pintando con la hoja nueva.
"""
from __future__ import annotations
from collections.abc import Iterator
from pathlib import Path
import pytest
import sqlalchemy as sa
from fastapi.testclient import TestClient
from sqlalchemy.orm import Session, sessionmaker
from app import audit
from app.config import get_settings
from app.db import crear_engine, crear_session_factory
from app.importers import lists as importador_listas
from app.importers.chm_schema import importar_esquema
from app.importers.matrix_v1 import importar_matriz_v1
from app.main import crear_app
from app.models import (
Alerta,
AuditTrail,
Base,
Cliente,
Coincidencia,
Credito,
EvaluacionRiesgo,
ModeloRiesgo,
)
from app.models.usuario import Rol
from app.services import alertas as servicio_alertas
from app.services import casos as servicio_casos
from app.services import operaciones as servicio_operaciones
from app.services import riesgo as servicio_riesgo
from app.services import screening as servicio_screening
from seed import plantar_casos
from seed.identidades_sinteticas import sembrar as sembrar_identidades
from seed.usuarios_demo import sembrar
from tests.fixtures import generar_operaciones_incremental as generador
from tests.test_expediente import CONTRASENAS, FIXTURE, entrar
from tests.test_operaciones import bytes_sin_fila_invalida
DIR_LISTAS = Path(__file__).parent / "fixtures" / "listas"
FECHA_EVIDENCIA = "2026-10-08"
def _con_actor(fabrica: sessionmaker[Session]) -> Session:
sesion = fabrica()
audit.fijar_actor(sesion, "pytest", 1)
return sesion
@pytest.fixture
def fabrica(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> sessionmaker[Session]:
engine = crear_engine("sqlite://")
Base.metadata.create_all(engine)
fabrica = crear_session_factory(engine)
monkeypatch.setattr("app.db.SessionLocal", fabrica)
monkeypatch.setattr(get_settings(), "data_dir", tmp_path)
servicio_screening.vaciar_cache()
servicio_operaciones._PREPARADAS.clear()
with fabrica() as sesion:
sembrar(sesion, CONTRASENAS)
sesion.commit()
importar_esquema(sesion, FIXTURE, "pytest", sal=generador.SAL)
servicio_riesgo.evaluar_cartera(sesion, "inicial")
servicio_alertas.ejecutar_reglas(sesion, usuario="pytest")
sembrar_identidades(sesion)
for nombre, lista in importador_listas.LISTAS.items():
archivo = next(DIR_LISTAS.glob(lista.patron_archivo))
importador_listas.importar_lista(sesion, nombre, archivo, usuario="pytest")
sesion.commit()
with _con_actor(fabrica) as sesion:
plantar_casos.plantar(sesion)
importar_matriz_v1(sesion)
sesion.commit()
with _con_actor(fabrica) as sesion:
preparada = servicio_operaciones.preparar_carga(
sesion, "carga.xlsx", bytes_sin_fila_invalida(), "pytest"
)
sesion.commit()
with _con_actor(fabrica) as sesion:
servicio_operaciones.confirmar_carga(sesion, preparada.token, "pytest")
sesion.commit()
with _con_actor(fabrica) as sesion:
abierta = sesion.scalar(
sa.select(Alerta.id).where(Alerta.estado != "cerrada").order_by(Alerta.id)
)
servicio_casos.abrir_caso(sesion, [abierta], responsable="analista", usuario="pytest")
sesion.commit()
return fabrica
@pytest.fixture
def cliente(fabrica: sessionmaker[Session]) -> Iterator[TestClient]:
with TestClient(crear_app(), follow_redirects=False) as c:
yield c
def _rutas(fabrica: sessionmaker[Session]) -> list[str]:
"""Todas las pantallas GET (las de detalle, con un id que existe en la base de prueba)."""
with fabrica() as s:
uno = lambda consulta: s.scalar(consulta.limit(1)) # noqa: E731
cliente_id = uno(sa.select(EvaluacionRiesgo.cliente_id).order_by(EvaluacionRiesgo.id))
moral_id = uno(sa.select(Cliente.id).where(Cliente.tipo_persona == "moral"))
credito_id = uno(sa.select(Credito.id).order_by(Credito.id))
alerta_id = uno(sa.select(Alerta.id).order_by(Alerta.id))
# La primera alerta abierta ya está en el caso de la fixture: escalar otra.
sin_caso_id = uno(
sa.select(Alerta.id).where(Alerta.estado != "cerrada").order_by(Alerta.id.desc())
)
coincidencia_id = uno(sa.select(Coincidencia.id).order_by(Coincidencia.id))
auditoria_id = uno(sa.select(AuditTrail.id).order_by(AuditTrail.id))
modelos = s.scalars(sa.select(ModeloRiesgo.id).order_by(ModeloRiesgo.id)).all()
caso_id = s.scalar(sa.text("SELECT max(id) FROM caso"))
lote_id = s.scalar(sa.text("SELECT max(id) FROM lote_carga"))
assert None not in (cliente_id, moral_id, credito_id, alerta_id, sin_caso_id, caso_id)
assert None not in (coincidencia_id, auditoria_id, lote_id)
assert len(modelos) >= 2
a, b = modelos[0], modelos[-1]
return [
"/inicio",
"/cartera",
"/expediente",
"/clientes/nuevo?tipo=fisica",
"/clientes/nuevo?tipo=moral",
f"/clientes/{cliente_id}",
f"/clientes/{moral_id}",
f"/clientes/{cliente_id}/identificacion",
"/beneficiario-controlador",
f"/clientes/{moral_id}/beneficiario",
"/screening",
"/screening/listas",
f"/screening/{coincidencia_id}",
"/riesgo",
"/riesgo?nivel=alto",
f"/riesgo/{cliente_id}",
"/creditos",
f"/creditos/{credito_id}",
"/operaciones",
"/operaciones/cargas",
f"/operaciones/cargas/{lote_id}",
"/operaciones/cierre",
"/alertas",
f"/alertas/{alerta_id}",
"/casos",
f"/casos/nuevo?alerta_id={sin_caso_id}",
f"/casos/{caso_id}",
"/evidencia",
f"/evidencia/{cliente_id}?fecha={FECHA_EVIDENCIA}",
"/auditoria",
f"/auditoria/{auditoria_id}",
"/laboratorio",
f"/laboratorio/versiones/{a}",
"/laboratorio/comparar",
f"/laboratorio/comparar?a={a}&b={b}",
]
def test_cada_pantalla_responde_y_pinta_la_estructura(
cliente: TestClient, fabrica: sessionmaker[Session]
) -> None:
assert cliente.get("/login").status_code == 200
entrar(cliente, Rol.OFICIAL)
estructura = ('<nav class="nav"', 'id="i-home"', "/static/app.css")
fallas = []
for ruta in _rutas(fabrica):
respuesta = cliente.get(ruta)
if respuesta.status_code != 200:
fallas.append(f"{ruta}: {respuesta.status_code}")
elif not all(pieza in respuesta.text for pieza in estructura):
fallas.append(f"{ruta}: falta la estructura común")
assert fallas == []
def test_el_acceso_no_pinta_la_estructura_con_sesion(client: TestClient) -> None:
html = client.get("/login").text
assert '<nav class="nav"' not in html and 'class="lateral"' not in html
assert "/static/app.css" in html