Skip to content

Commit

Permalink
feat: add column destination to list import
Browse files Browse the repository at this point in the history
Add column "Destination" to list import (front)
Make column sortable (backend)

Reviewed-by: andriac
  • Loading branch information
andriacap committed Jan 30, 2024
1 parent e4555cd commit 8f349d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/geonature/core/imports/routes/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ <h5 class="card-title mb-0">Liste des imports</h5>
</ng-container>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column maxWidth="200" name="Destination" [sortable]="true" prop="dest_label">
<ng-template let-row="row" ngx-datatable-cell-template>
<p *ngIf="row.destination">{{row.destination.code}}</p>
</ng-template>
</ngx-datatable-column>
<ngx-datatable-column
maxWidth="200"
name="Fin import"
Expand All @@ -80,6 +85,7 @@ <h5 class="card-title mb-0">Liste des imports</h5>
<p *ngIf="checkingImport.includes(row.id_import)" class="import-status">vérifications en cours</p>
</ng-template>
</ngx-datatable-column>

<ngx-datatable-column
name="Actions"
[sortable]="false"
Expand Down

0 comments on commit 8f349d6

Please sign in to comment.