Projet

Général

Profil

0001-base_adresse-set-result-id-to-lookup-id-72263.patch

Benjamin Dauvergne, 12 décembre 2022 10:11

Télécharger (1,55 ko)

Voir les différences:

Subject: [PATCH] base_adresse: set result id to lookup id (#72263)

base_adresse data source ids are not canonical, many can match the same
adress. But clients of the API does not handle this well, so it's better
to always return the same id event if we know it has changed.
 passerelle/apps/base_adresse/models.py | 7 +++++++
 1 file changed, 7 insertions(+)
passerelle/apps/base_adresse/models.py
198 198
            results = self.addresses(request, q=q, lat=lat, lon=lon, citycode=citycode)['data']
199 199
            for result in results:  # match by id if possible
200 200
                if result['ban_id'] == ban_id:
201
                    # Keep the original id if the client revalidate the
202
                    # response before accepting it (like w.c.s. does).
203
                    # id can change if street name changes (case change for
204
                    # example).
205
                    # See https://dev.entrouvert.org/issues/72263
206
                    result = result.copy()
207
                    result['id'] = id
201 208
                    return {'data': [result]}
202 209
            self.logger.error('get_by_id: id %s was not found', id)
203 210
        return {'err': _('Address ID not found')}
204
-