feat(5.20): US-010 badge mediu RAR in liste/preview/detaliu/jurnal + audit + ecou API
labels.py: ETICHETE_ENV + eticheta_env(env)->(text,css). Productie afisata
"PRODUCȚIE" (majuscule+diacritice) cu badge fill de atentie (--err), Testare
outline discret muted — semnalizare risc L.142 (declaratie reala ireversibila).
Clase .env-badge-prod / .env-badge-test in base.html; eticheta_env expus ca
global Jinja.
Badge de mediu per rand in _submissions, _coada implicit prin view, _preview_rand,
_trimitere_detaliu, _jurnal. Statusbar (_status.html) aliniat la aceeasi conventie
(Productie = atentie, nu verde) — inlocuieste culorile ad-hoc din US-011, toggle
neatins.
rar_env in exportul de audit (AUDIT_COLUMNS + _audit_rows) si ecou in
GET /v1/prezentari(/{id}). _submission_row_view/_detaliu_ctx/fragment_submissions
duc rar_env pana in template.
tests/test_badge_rar_env.py: badge in lista, audit contine rar_env, GET ecou rar_env.
test_statusbar_env: asertie aliniata la eticheta PRODUCȚIE.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -556,6 +556,8 @@ AUDIT_COLUMNS = [
|
||||
"odometru_final",
|
||||
"prestatii",
|
||||
"rar_status_code",
|
||||
# US-010 (PRD 5.20): mediul RAR tinta per trimitere.
|
||||
"rar_env",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"purge_after",
|
||||
@@ -571,7 +573,7 @@ def _audit_rows(conn, date_from: str | None, date_to: str | None, status: str, a
|
||||
scope_sql, scope_params = account_scope_clause(account_id)
|
||||
sql = (
|
||||
"SELECT id, status, id_prezentare, account_id, payload_json, rar_status_code, "
|
||||
"created_at, updated_at, purge_after FROM submissions"
|
||||
"rar_env, created_at, updated_at, purge_after FROM submissions"
|
||||
)
|
||||
where = [scope_sql]
|
||||
params: list = list(scope_params)
|
||||
@@ -609,6 +611,8 @@ def _audit_rows(conn, date_from: str | None, date_to: str | None, status: str, a
|
||||
"odometru_final": p.get("odometru_final") or "",
|
||||
"prestatii": codes,
|
||||
"rar_status_code": r["rar_status_code"] or "",
|
||||
# US-010 (PRD 5.20): mediul RAR tinta — coloana audit.
|
||||
"rar_env": r["rar_env"] or "",
|
||||
"created_at": r["created_at"],
|
||||
"updated_at": r["updated_at"],
|
||||
"purge_after": r["purge_after"] or "",
|
||||
|
||||
@@ -401,6 +401,31 @@ def nota_umana_preview(status: str, errors: list, flags: list) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Etichete mediu RAR (Test / Productie) — US-010 PRD 5.20
|
||||
#
|
||||
# Conventia de culori (semantica risc L.142):
|
||||
# prod = env-badge-prod (fill atentie, text alb) — declaratie REALA, ireversibila.
|
||||
# test = env-badge-test (outline discret, --muted) — mediu de proba.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
ETICHETE_ENV: dict[str, tuple[str, str]] = {
|
||||
"prod": ("PRODUCȚIE", "env-badge-prod"),
|
||||
"test": ("Testare", "env-badge-test"),
|
||||
}
|
||||
|
||||
|
||||
def eticheta_env(env: object) -> tuple[str, str]:
|
||||
"""Returneaza (text, css_class) pentru mediul RAR.
|
||||
|
||||
Fallback sigur: env necunoscut sau None -> ('Testare', 'env-badge-test').
|
||||
Nu arunca niciodata.
|
||||
"""
|
||||
if not env:
|
||||
return ("Testare", "env-badge-test")
|
||||
return ETICHETE_ENV.get(str(env), ("Testare", "env-badge-test"))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Constante auxiliare (microcopy fix, fara logica)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -32,6 +32,7 @@ from ..web.csrf import get_csrf_token, verify_csrf
|
||||
from .labels import (
|
||||
ETICHETA_ULTIMA_AUTENTIFICARE_RAR,
|
||||
STARI_PREVIEW,
|
||||
eticheta_env,
|
||||
eticheta_rar,
|
||||
eticheta_scurta,
|
||||
eticheta_stare,
|
||||
@@ -110,8 +111,9 @@ def _import_env_ctx(conn, account_id: int) -> dict:
|
||||
|
||||
router = APIRouter(tags=["web"])
|
||||
templates = Jinja2Templates(directory=str(Path(__file__).resolve().parent / "templates"))
|
||||
# Expune parse_erori in toate template-urile
|
||||
# Expune parse_erori si eticheta_env in toate template-urile
|
||||
templates.env.globals["parse_erori"] = parse_erori
|
||||
templates.env.globals["eticheta_env"] = eticheta_env
|
||||
|
||||
_BLOCKED = ("error", "needs_data", "needs_mapping")
|
||||
|
||||
@@ -528,6 +530,8 @@ def _jurnal_context(
|
||||
"has_more": has_more,
|
||||
"prev_page": page - 1 if page > 0 else None,
|
||||
"next_page": page + 1 if has_more else None,
|
||||
# US-010 (PRD 5.20): mediul implicit al contului pentru badge de sectiune.
|
||||
"env_default": rar_env_efectiv_cont(conn, account_id) or "test",
|
||||
}
|
||||
|
||||
|
||||
@@ -1042,6 +1046,8 @@ def _submission_row_view(r) -> dict:
|
||||
# randurile blocate (error/needs_data/needs_mapping) sunt selectabile pentru
|
||||
# stergere bulk; sent/sending/queued raman read-only (fara checkbox).
|
||||
"gestionabil": r["status"] in _GESTIONABILE_WEB,
|
||||
# US-010 (PRD 5.20): mediul RAR tinta — badge in lista.
|
||||
"rar_env": r["rar_env"] if "rar_env" in r.keys() else None,
|
||||
}
|
||||
|
||||
|
||||
@@ -1089,7 +1095,7 @@ def fragment_submissions(
|
||||
# FARA LIMIT — altfel paginile >8 ar disparea silentios.
|
||||
rows_db = conn.execute(
|
||||
"SELECT id, status, id_prezentare, rar_status_code, rar_error, retry_count, "
|
||||
f"updated_at, payload_json FROM submissions WHERE {where_sql} ORDER BY id DESC",
|
||||
f"updated_at, payload_json, rar_env FROM submissions WHERE {where_sql} ORDER BY id DESC",
|
||||
params,
|
||||
).fetchall()
|
||||
|
||||
@@ -1130,7 +1136,7 @@ def fragment_submissions(
|
||||
|
||||
rows_db = conn.execute(
|
||||
"SELECT id, status, id_prezentare, rar_status_code, rar_error, retry_count, "
|
||||
f"updated_at, payload_json FROM submissions WHERE {where_sql} ORDER BY id DESC "
|
||||
f"updated_at, payload_json, rar_env FROM submissions WHERE {where_sql} ORDER BY id DESC "
|
||||
"LIMIT ? OFFSET ?",
|
||||
params + [_PAGE_SIZE, offset],
|
||||
).fetchall()
|
||||
@@ -1352,6 +1358,8 @@ def _detaliu_ctx(request: Request, row, *, message: str | None = None,
|
||||
"editabil": row["status"] in _CORECTABILE,
|
||||
# error/needs_data/needs_mapping pot fi sterse / re-puse in coada
|
||||
"gestionabil": row["status"] in _GESTIONABILE_WEB,
|
||||
# US-010 (PRD 5.20): mediul RAR tinta — badge in detaliu.
|
||||
"rar_env": row["rar_env"] if "rar_env" in row.keys() else None,
|
||||
# mapare inline (operatii nemapate ale acestui rand + nomenclator)
|
||||
"nemapate_inline": nemapate_inline,
|
||||
"nomenclator": nomenclator,
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
{% else %}
|
||||
<span class="muted" style="font-size:12px;">doar evenimentele contului tau</span>
|
||||
{% endif %}
|
||||
{# Badge mediu RAR activ (US-010 PRD 5.20) — mediul implicit al contului #}
|
||||
{% if env_default | default('') %}
|
||||
{% set _eb = eticheta_env(env_default) %}
|
||||
<span class="{{ _eb[1] }}" style="margin-left:auto;" title="Mediu RAR activ">{{ _eb[0] }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<form id="filtre-jurnal"
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
<span class="pill {{ row.stare_css }}" style="display:inline-flex; align-items:center; gap:5px;"
|
||||
{% if _nota %}title="{{ _nota }}"{% endif %}>
|
||||
<span aria-hidden="true" style="display:inline-block; width:7px; height:7px; border-radius:99px; background:currentColor; flex-shrink:0;"></span>{{ row.stare_eticheta }}</span>
|
||||
{# Badge mediu RAR (US-010 PRD 5.20) — rar_env disponibil din contextul batch-ului. #}
|
||||
{% if rar_env | default('') %}
|
||||
{% set _eb = eticheta_env(rar_env) %}
|
||||
<div style="margin-top:3px;"><span class="{{ _eb[1] }}">{{ _eb[0] }}</span></div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="col-vehicul" data-eticheta="Vehicul">
|
||||
{{ row.prez.vehicul_nr }}
|
||||
|
||||
@@ -127,19 +127,19 @@
|
||||
La 0 medii: nu afisa (cont fara configuratie RAR).
|
||||
La 1 mediu: eticheta statica (fara toggle).
|
||||
La 2 medii: buton de comutare HTMX (toggle conditionat).
|
||||
US-010: culori prin eticheta_env/clase .env-badge-* (consistenta cu badge-urile din liste).
|
||||
#}
|
||||
{% set _medii = medii_disponibile | default([]) %}
|
||||
{% set _env = env_default | default('prod') %}
|
||||
{% set _env_label = "Testare" if _env == "test" else "Productie" %}
|
||||
{% set _eb = eticheta_env(_env) %}
|
||||
{% if _medii | length >= 1 %}
|
||||
<div class="env-indicator"
|
||||
style="display:flex; align-items:center; gap:8px; margin-bottom:10px;
|
||||
padding:6px 10px; border-radius:6px; font-size:var(--fs-sm);
|
||||
background:color-mix(in srgb, {% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %} 12%, var(--card));
|
||||
border:1px solid color-mix(in srgb, {% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %} 30%, transparent);">
|
||||
<span style="font-weight:600; color:{% if _env == 'test' %}var(--warn){% else %}var(--ok){% endif %};">
|
||||
Mediu RAR: {{ _env_label }}
|
||||
</span>
|
||||
background:color-mix(in srgb, {% if _env == 'prod' %}var(--err){% else %}var(--line){% endif %} 10%, var(--card));
|
||||
border:1px solid color-mix(in srgb, {% if _env == 'prod' %}var(--err){% else %}var(--line){% endif %} 30%, transparent);">
|
||||
<span style="font-weight:600;">Mediu RAR:</span>
|
||||
<span class="{{ _eb[1] }}">{{ _eb[0] }}</span>
|
||||
{% if _medii | length >= 2 %}
|
||||
{# Toggle: apare DOAR cand sunt cel putin 2 medii disponibile #}
|
||||
<form method="post" action="/_fragments/status/toggle-env"
|
||||
@@ -152,7 +152,7 @@
|
||||
style="padding:2px 10px; font-size:var(--fs-xs); border-radius:99px;
|
||||
border:1px solid currentColor; background:transparent; cursor:pointer;
|
||||
color:var(--muted); line-height:1.4;"
|
||||
title="Comuta la {{ 'Productie' if _env == 'test' else 'Testare' }}">
|
||||
title="Comuta la {{ 'PRODUCȚIE' if _env == 'test' else 'Testare' }}">
|
||||
Comuta
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -136,9 +136,14 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{# Pill de stare — dreapta, flex:none #}
|
||||
<span class="pill {{ r.stare_css }}" title="{{ r.stare_text }}"
|
||||
style="flex:0 0 auto; white-space:nowrap;">{{ r.stare_scurt }}</span>
|
||||
{# Zona dreapta: pill stare + badge mediu RAR (US-010 PRD 5.20) #}
|
||||
<div style="flex:0 0 auto; display:flex; flex-direction:column; align-items:flex-end; gap:3px; white-space:nowrap;">
|
||||
<span class="pill {{ r.stare_css }}" title="{{ r.stare_text }}">{{ r.stare_scurt }}</span>
|
||||
{% if r.rar_env %}
|
||||
{% set _eb = eticheta_env(r.rar_env) %}
|
||||
<span class="{{ _eb[1] }}">{{ _eb[0] }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@@ -7,10 +7,14 @@
|
||||
{% set cod_afis = prez.cod_rar if (prez.cod_rar and prez.cod_rar != '—') else 'nemapat' %}
|
||||
<div class="card" id="detaliu-card-{{ id }}" style="border:none; padding:0; margin:0;">
|
||||
|
||||
{# === Header — #id + pill + motiv uman === #}
|
||||
{# === Header — #id + pill stare + badge mediu RAR (US-010 PRD 5.20) + motiv === #}
|
||||
<div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:0 0 8px;">
|
||||
<h2 id="detaliu-modal-titlu" style="font-size:15px; margin:0;">Detaliu trimitere #{{ id }}</h2>
|
||||
<span class="pill {{ stare_css }}">{{ stare_text }}</span>
|
||||
{% if rar_env %}
|
||||
{% set _eb = eticheta_env(rar_env) %}
|
||||
<span class="{{ _eb[1] }}" title="Mediu RAR: {{ _eb[0] }}">{{ _eb[0] }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if motiv %}
|
||||
<p class="muted" style="margin:0 0 12px; font-size:13px;">{{ motiv }}</p>
|
||||
|
||||
@@ -142,6 +142,14 @@
|
||||
.s-ok{color:var(--ok);}
|
||||
.s-needs_review{color:var(--warn);}
|
||||
.s-already_sent,.s-duplicate_in_file{color:var(--muted);}
|
||||
/* Badge mediu RAR (US-010 PRD 5.20) — semantica risc L.142.
|
||||
Productie: fill atentie (ton --err), text alb — declaratie reala, ireversibila.
|
||||
Testare: outline discret, ton --muted — mediu de proba, low-stakes.
|
||||
NU se foloseste verde pentru Productie (ar semnala "sigur"). */
|
||||
.env-badge-prod { display:inline-block; padding:1px 7px; border-radius:99px; font-size:11px; font-weight:700; letter-spacing:.02em;
|
||||
background:color-mix(in srgb, var(--err) 80%, var(--card)); color:#fff; border:1px solid transparent; }
|
||||
.env-badge-test { display:inline-block; padding:1px 7px; border-radius:99px; font-size:11px;
|
||||
background:transparent; color:var(--muted); border:1px solid var(--line); }
|
||||
.muted { color:var(--muted); }
|
||||
/* Heading/eticheta accesibila doar pentru cititoare de ecran (vizual ascunsa). */
|
||||
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden;
|
||||
|
||||
Reference in New Issue
Block a user