From 1afb7647e9436b890c3a2fca2a04ab585a6a38c0 Mon Sep 17 00:00:00 2001 From: Christophe Boulanger Date: Fri, 14 Jun 2019 10:18:49 +0200 Subject: [PATCH] Liege : Some modifications to use new service (with commissariat,...) --- passerelle_imio_liege_lisrue/models.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/passerelle_imio_liege_lisrue/models.py b/passerelle_imio_liege_lisrue/models.py index b99c203..1286756 100644 --- a/passerelle_imio_liege_lisrue/models.py +++ b/passerelle_imio_liege_lisrue/models.py @@ -29,6 +29,7 @@ from passerelle.utils.api import endpoint class ImioLiegeLisrue(BaseResource): PROFILE_CHOICES = ( ('LIEGE','Liege'), + ('LIEGE_BETA','Liege lisrue2 beta'), ('NAMUR','Namur'), ) service_url = models.CharField(max_length=128, blank=False, @@ -44,7 +45,6 @@ class ImioLiegeLisrue(BaseResource): verbose_name=_('Check HTTPS Certificate validity')) category = _('Geographic information system') - class Meta: verbose_name = _('Liege Lisrue Service') @@ -66,7 +66,10 @@ class ImioLiegeLisrue(BaseResource): if self.include_all_of_belgium: url += 'jsonlisrue/' else: - url += 'jsonlisrue2/' + if self.profile == 'LIEGE_BETA': + url += 'jsonlgrue2com/' + else: + url += 'jsonlisrue2/' if q: q = unicodedata.normalize('NFKD', request.GET['q']).encode('ascii', 'ignore') @@ -101,7 +104,17 @@ class ImioLiegeLisrue(BaseResource): street_label = u"{} - {}".format(street_label, str(item.get('codePostal'))).strip() else: street_label = street_label.strip() - streets.append({ + + if (self.profile == 'LIEGE_BETA'): + if item.get('statutVO') is not None and item.get('statutVO').get('code') == '1': + streets.append({ + 'id': item.get('codeRue'), + 'text': street_label, + 'codeCommissariat': item.get('commissariat').get('codeCommissariat') if item.get('commissariat') else '', + 'libelleCommissariat': item.get('commissariat').get('libelleCommissariat') if item.get('commissariat') else '' + }) + else: + streets.append({ 'id': item.get('codeRue'), 'text': street_label, })