g3w-suite / g3w-admin

Server module for G3W-SUITE
https://g3w-suite.readthedocs.io/en/latest/g3wsuite_administration.html
Mozilla Public License 2.0
39 stars 31 forks source link

Ordering by `fformatter` field. #807

Closed wlorenzetti closed 2 months ago

wlorenzetti commented 2 months ago

Closes: #806

Apply the orderign URl parameter on field set by fformatter parameter.

Without ordering parameter:

http://localhost:8006/vector/api/data/qdjango/336/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/?fformatter=address&format=json
  "data": [
    [ "A101",  "Via Sallustio Bandini" ],
    [ "A102",   "Via Atto Vannucci" ],
    [ "A103",   "Via Alfredo Oriani gia' Via Vecchia" ],
    [ "A106",   "Piazza Pietro Leopoldo" ],
    [ "A107",   "Via Ubaldo Montelatici" ],
    [ "A108",   "Via Giandomenico Romagnosi" ],
    [ "B002",  "Via Giovanni Lampredi" ]
]

With ordering parameter (ordering=address):

http://localhost:8006/vector/api/data/qdjango/336/buildings_2f43dc1d_6725_42d2_a09b_dd446220104a/?fformatter=address&format=json&ordering=address

"data": [
    [ "A106",  "Piazza Pietro Leopoldo" ],
    [ "A103",  "Via Alfredo Oriani gia' Via Vecchia" ],
    [ "A102",  "Via Atto Vannucci" ],
    [ "A108",  "Via Giandomenico Romagnosi" ],
    [ "B002",  "Via Giovanni Lampredi" ],
    [ "A101",  "Via Sallustio Bandini" ],
    [ "A107",  "Via Ubaldo Montelatici" ]
  ]

Also works with - i.e. ordering=-address fro reversing results.

IMPORTANT

The sorting of results is made by str.sort() python function