From 8f349d687d727dc7fc82624751b633e6f1464cd2 Mon Sep 17 00:00:00 2001 From: Andria Capai Date: Tue, 30 Jan 2024 18:51:19 +0100 Subject: [PATCH] feat: add column destination to list import Add column "Destination" to list import (front) Make column sortable (backend) Reviewed-by: andriac --- backend/geonature/core/imports/routes/imports.py | 13 +++++++++++-- .../import_list/import-list.component.html | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/geonature/core/imports/routes/imports.py b/backend/geonature/core/imports/routes/imports.py index 16b4f650b2..2f073e85f2 100644 --- a/backend/geonature/core/imports/routes/imports.py +++ b/backend/geonature/core/imports/routes/imports.py @@ -10,7 +10,7 @@ from urllib.parse import quote as url_quote from sqlalchemy import or_, func, desc, select, delete from sqlalchemy.inspection import inspect -from sqlalchemy.orm import joinedload, Load, load_only, undefer, contains_eager +from sqlalchemy.orm import joinedload, Load, load_only, undefer, contains_eager, lazyload from sqlalchemy.orm.attributes import set_committed_value from sqlalchemy.sql.expression import collate, exists @@ -80,6 +80,10 @@ def get_import_list(scope, destination=None): sort = request.args.get("sort", default="date_create_import", type=str) sort_dir = request.args.get("sort_dir", default="desc", type=str) filters = [] + + if sort == "dest_label": + sort = "destination.label" + if search: filters.append(TImports.full_file_name.ilike(f"%{search}%")) filters.append( @@ -109,9 +113,14 @@ def get_import_list(scope, destination=None): order_by = desc(order_by) query = ( - TImports.query.options(contains_eager(TImports.dataset), contains_eager(TImports.authors)) + TImports.query.options( + contains_eager(TImports.dataset), + contains_eager(TImports.authors), + lazyload(TImports.destination).load_only(Destination.label), + ) .join(TImports.dataset, isouter=True) .join(TImports.authors, isouter=True) + .join(Destination, Destination.id_destination == TImports.id_destination) .filter_by_scope(scope) .filter(or_(*filters) if len(filters) > 0 else True) .order_by(order_by) diff --git a/frontend/src/app/modules/imports/components/import_list/import-list.component.html b/frontend/src/app/modules/imports/components/import_list/import-list.component.html index 3490346959..8e7ec1f328 100644 --- a/frontend/src/app/modules/imports/components/import_list/import-list.component.html +++ b/frontend/src/app/modules/imports/components/import_list/import-list.component.html @@ -63,6 +63,11 @@
Liste des imports
+ + +

{{row.destination.code}}

+
+
Liste des imports

vérifications en cours

+