Skip to content

Commit

Permalink
FIX : code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
neo-garaix committed Nov 8, 2024
1 parent 8ba3bc0 commit b47cead
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions lizmap_server/expression_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,24 +880,18 @@ def virtualFields(params: Dict[str, str], response: QgsServerResponse, project:

# set orderby
req_sorting_order_param = params.get('SORTING_ORDER', '')
# Initialize to a default value
req_sorting_order = ''

if req_sorting_order_param in ['asc', 'desc']:
if req_sorting_order_param in ('asc', 'desc'):
# QGIS expects a boolean to know how to sort
req_sorting_order = (req_sorting_order_param == 'asc')
req_sorting_field = params.get('SORTING_FIELD', '')
order_by_clause = QgsFeatureRequest.OrderByClause(req_sorting_field, req_sorting_order_param == 'asc')
req.setOrderBy(QgsFeatureRequest.OrderBy([order_by_clause]))
elif req_sorting_order_param != '' :
raise ExpressionServiceError(
"Bad request error",
f"Invalid SORTING_ORDER for 'VirtualFields': \"{req_sorting_order_param}\"",
400)

req_sorting_field = params.get('SORTING_FIELD', '')

if type(req_sorting_order) is bool :
order_by_clause = QgsFeatureRequest.OrderByClause(req_sorting_field, req_sorting_order)
req.setOrderBy(QgsFeatureRequest.OrderBy([order_by_clause]))

# get filter
req_filter = params.get('FILTER', '')
if req_filter:
Expand Down

0 comments on commit b47cead

Please sign in to comment.