map marker legibility, PDF export blueprint fix, asset list type search
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from flask import Blueprint, request
|
||||
from flask_jwt_extended import jwt_required
|
||||
|
||||
from shopdb.api import db, Asset, AssetType, AuditLog, success_response, error_response, paginated_response, ErrorCodes, get_pagination_params, paginate_query, resolve_dualpath_pairs, dualpath_single_machine_enabled
|
||||
from shopdb.api import db, Asset, AssetType, AuditLog, Vendor, success_response, error_response, paginated_response, ErrorCodes, get_pagination_params, paginate_query, resolve_dualpath_pairs, dualpath_single_machine_enabled
|
||||
|
||||
from ..models import Machine, MachineType
|
||||
|
||||
@@ -174,13 +174,23 @@ def list_machines():
|
||||
if exactassetnumber := request.args.get('assetnumber'):
|
||||
query = query.filter(Asset.assetnumber == exactassetnumber)
|
||||
|
||||
# Search filter
|
||||
# Search filter. Covers what the list actually SHOWS - the asset fields plus
|
||||
# the type and vendor names, which are columns in the table. Searching a type
|
||||
# like 'Part Washer' used to return nothing. Outer joins so a machine with no
|
||||
# type or vendor still matches on its own fields.
|
||||
if search := request.args.get('search'):
|
||||
query = query.filter(
|
||||
pattern = f'%{search}%'
|
||||
query = query.outerjoin(
|
||||
MachineType, Machine.machinetypeid == MachineType.machinetypeid
|
||||
).outerjoin(
|
||||
Vendor, Machine.vendorid == Vendor.vendorid
|
||||
).filter(
|
||||
db.or_(
|
||||
Asset.assetnumber.ilike(f'%{search}%'),
|
||||
Asset.name.ilike(f'%{search}%'),
|
||||
Asset.serialnumber.ilike(f'%{search}%')
|
||||
Asset.assetnumber.ilike(pattern),
|
||||
Asset.name.ilike(pattern),
|
||||
Asset.serialnumber.ilike(pattern),
|
||||
MachineType.machinetype.ilike(pattern),
|
||||
Vendor.vendor.ilike(pattern)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user