toulouse_smart: pass optionnal boolean parameters to create endpoint (#56630)

This commit is contained in:
Nicolas Roche 2021-09-03 15:21:27 +02:00
parent 28576589a8
commit f39941dd93
3 changed files with 19 additions and 3 deletions

View File

@ -221,6 +221,9 @@ class ToulouseSmartResource(BaseResource, HTTPResource):
'interventionTypeId': intervention_type['id'],
'notificationUrl': '%s?uuid=%s' % (update_intervention_endpoint_url, wcs_request.uuid),
}
for label in 'checkDuplicated', 'onPrivateLand', 'safeguardRequired':
if str(post_data.get(label)).lower() in ['true', 'oui', '1']:
wcs_request.payload[label] = 'true'
wcs_request.save()
if not wcs_request.push():
self.add_job(

View File

@ -15,6 +15,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
BOOLEAN_TYPES = [
{'type': 'boolean'},
{
'type': 'string',
'pattern': '[Oo][Uu][Ii]|[Nn][Oo][Nn]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|1|0',
},
]
CREATE_SCHEMA = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
@ -41,7 +49,7 @@ CREATE_SCHEMA = {
},
'safeguardRequired': {
'description': 'Présence dun danger ?',
'type': 'boolean',
'oneOf': BOOLEAN_TYPES,
},
'interventionCreated': {
'description': 'Date de création de la demande',
@ -79,11 +87,11 @@ CREATE_SCHEMA = {
},
'onPrivateLand': {
'description': 'Intervention sur le domaine privé ?',
'type': 'boolean',
'oneOf': BOOLEAN_TYPES,
},
'checkDuplicated': {
'description': 'Activation de la détection de doublon (laisser à false pour le moment)',
'type': 'boolean',
'oneOf': BOOLEAN_TYPES,
},
'external_number': {
'description': 'Numéro externe de la demande (numéro Publik : {{ form_number }})',

View File

@ -284,6 +284,9 @@ CREATE_INTERVENTION_PAYLOAD_EXTRA = {
'external_status': 'statut-1-wcs',
'address': 'https://wcs.example.com/backoffice/management/foo/2/',
'form_api_url': 'https://wcs.example.com/api/forms/foo/2/',
'checkDuplicated': 'False',
'onPrivateLand': 'True',
'safeguardRequired': True,
}
@ -323,6 +326,8 @@ CREATE_INTERVENTION_QUERY = {
'geom': {'type': 'Point', 'coordinates': [2.323349, 48.833708], 'crs': 'EPSG:4326'},
'interventionTypeId': '1234',
'notificationUrl': 'http://testserver/toulouse-smart/test/update-intervention?uuid=%s' % str(UUID),
'onPrivateLand': 'true',
'safeguardRequired': 'true',
}