feat(documents): enrich FDS global view
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
This commit is contained in:
parent
b20e33299e
commit
20acfa9d18
2 changed files with 10 additions and 2 deletions
|
|
@ -48,6 +48,8 @@ class DocumentResult:
|
||||||
filepath: str
|
filepath: str
|
||||||
location_labels: tuple[str, ...]
|
location_labels: tuple[str, ...]
|
||||||
location_summary: str
|
location_summary: str
|
||||||
|
version: Optional[str] = None
|
||||||
|
issuer: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
def _location_path(room):
|
def _location_path(room):
|
||||||
|
|
@ -107,7 +109,8 @@ def _summary(locations):
|
||||||
|
|
||||||
|
|
||||||
def _result(source, document, parent, *, title, document_type, description,
|
def _result(source, document, parent, *, title, document_type, description,
|
||||||
document_date, context_label, context_url, locations):
|
document_date, context_label, context_url, locations, version=None,
|
||||||
|
issuer=None):
|
||||||
return DocumentResult(
|
return DocumentResult(
|
||||||
source=source,
|
source=source,
|
||||||
source_id=document.id,
|
source_id=document.id,
|
||||||
|
|
@ -124,6 +127,8 @@ def _result(source, document, parent, *, title, document_type, description,
|
||||||
filepath=document.filepath,
|
filepath=document.filepath,
|
||||||
location_labels=tuple(locations),
|
location_labels=tuple(locations),
|
||||||
location_summary=_summary(locations),
|
location_summary=_summary(locations),
|
||||||
|
version=version,
|
||||||
|
issuer=issuer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -173,6 +178,9 @@ def list_documents(*, query="", source=None, document_type=None,
|
||||||
context_label=f"Produit — {label}",
|
context_label=f"Produit — {label}",
|
||||||
context_url=url_for("cleaning.references", highlight=parent.id),
|
context_url=url_for("cleaning.references", highlight=parent.id),
|
||||||
locations=_product_locations(parent),
|
locations=_product_locations(parent),
|
||||||
|
version=document.version,
|
||||||
|
issuer=(parent.manufacturer.name if parent.manufacturer else None)
|
||||||
|
or (parent.supplier.name if parent.supplier else None),
|
||||||
))
|
))
|
||||||
needle = (query or "").strip().casefold()
|
needle = (query or "").strip().casefold()
|
||||||
if needle:
|
if needle:
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,5 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container-fluid main-content"><div class="d-flex justify-content-between align-items-center mb-3"><div><h1 class="h3">Fiches de données de sécurité</h1><p class="text-muted">Les FDS sont consultées depuis les documents des références commerciales accessibles.</p></div><a class="btn btn-outline-secondary" href="{{ url_for('documents.index') }}">Centre documentaire</a></div>
|
<div class="container-fluid main-content"><div class="d-flex justify-content-between align-items-center mb-3"><div><h1 class="h3">Fiches de données de sécurité</h1><p class="text-muted">Les FDS sont consultées depuis les documents des références commerciales accessibles.</p></div><a class="btn btn-outline-secondary" href="{{ url_for('documents.index') }}">Centre documentaire</a></div>
|
||||||
<form class="row g-2 mb-3"><div class="col-md-8"><label for="q" class="visually-hidden">Rechercher un produit</label><input id="q" name="q" class="form-control" value="{{ filters.get('q','') }}" placeholder="Produit, fabricant ou référence"></div><div class="col-md-2"><button class="btn btn-primary" type="submit">Rechercher</button></div></form>
|
<form class="row g-2 mb-3"><div class="col-md-8"><label for="q" class="visually-hidden">Rechercher un produit</label><input id="q" name="q" class="form-control" value="{{ filters.get('q','') }}" placeholder="Produit, fabricant ou référence"></div><div class="col-md-2"><button class="btn btn-primary" type="submit">Rechercher</button></div></form>
|
||||||
{% if results %}<div class="table-responsive table-responsive-stack"><table class="table table-hover"><thead><tr><th>Produit</th><th>Fichier</th><th>Version</th><th>Localisation</th><th>Action</th></tr></thead><tbody>{% for item in results %}<tr><td data-label="Produit">{% if item.context_url %}<a href="{{ item.context_url }}">{{ item.context_label }}</a>{% else %}{{ item.context_label }}{% endif %}</td><td data-label="Fichier">{{ item.filename }}</td><td data-label="Version">{{ item.document_type_label }}</td><td data-label="Localisation">{{ item.location_summary }}</td><td data-label="Action"><a class="btn btn-sm btn-outline-primary" href="{{ item.download_url }}">Télécharger</a></td></tr>{% endfor %}</tbody></table></div>{% else %}<div class="alert alert-info">Aucune FDS accessible n'a été trouvée.</div>{% endif %}</div>
|
{% if results %}<div class="table-responsive table-responsive-stack"><table class="table table-hover"><thead><tr><th>Produit</th><th>Fabricant/fournisseur</th><th>Fichier</th><th>Version/date</th><th>Emplacements</th><th>Action</th></tr></thead><tbody>{% for item in results %}<tr><td data-label="Produit">{% if item.context_url %}<a href="{{ item.context_url }}">{{ item.context_label }}</a>{% else %}{{ item.context_label }}{% endif %}</td><td data-label="Fabricant/fournisseur">{{ item.issuer or '—' }}</td><td data-label="Fichier">{{ item.filename }}</td><td data-label="Version/date">{{ item.version or '—' }}{% if item.document_date %}<br><small>{{ item.document_date|datetime_fmt }}</small>{% endif %}</td><td data-label="Emplacements">{{ item.location_summary }}</td><td data-label="Action"><a class="btn btn-sm btn-outline-primary" href="{{ item.download_url }}">Télécharger</a></td></tr>{% endfor %}</tbody></table></div>{% else %}<div class="alert alert-info">Aucune FDS accessible n'a été trouvée.</div>{% endif %}</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue