From b51b3424f2b7d43b3f127bf8ce780d1a7304c637 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Wed, 20 Jul 2022 18:52:40 +0200
Subject: [PATCH] toulouse_maelis: remove translations (#67565)

---
 passerelle/contrib/toulouse_maelis/models.py | 84 ++++++++++----------
 1 file changed, 41 insertions(+), 43 deletions(-)

diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py
index 07abae2f..edbe4e16 100644
--- a/passerelle/contrib/toulouse_maelis/models.py
+++ b/passerelle/contrib/toulouse_maelis/models.py
@@ -14,47 +14,45 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from urllib.parse import urljoin
 
 import zeep
 from django.core.cache import cache
 from django.db import models
-from django.utils.translation import ugettext_lazy as _
 from zeep.helpers import serialize_object
 from zeep.wsse.username import UsernameToken
 
 from passerelle.base.models import BaseResource, HTTPResource
 from passerelle.utils.api import endpoint
 from passerelle.utils.jsonresponse import APIError
 
 from . import schemas
 
 
 class ToulouseMaelis(BaseResource, HTTPResource):
     base_wsdl_url = models.CharField(
         max_length=128,
         blank=False,
-        verbose_name=_('Base WSDL URL'),
-        help_text=_('Toulouse Maelis base WSDL URL'),
+        verbose_name='URL de base des WSDL',
         default='https://demo-toulouse.sigec.fr/maelisws-toulouse/services/',
     )
     zeep_wsse_username = models.CharField(
-        max_length=64, blank=True, default='', verbose_name=_('WSSE Username')
+        max_length=64, blank=True, default='', verbose_name='Identifiant utilisateur WSSE'
     )
     zeep_wsse_password = models.CharField(
-        max_length=64, blank=True, default='', verbose_name=_('WSSE Password')
+        max_length=64, blank=True, default='', verbose_name='Mot de passe WSSE'
     )
 
-    category = _('Business Process Connectors')
-    _category_ordering = [_('Family'), _('Activities')]
+    category = 'Connecteurs métiers'
+    _category_ordering = ['Famille', 'Activités']
 
     class Meta:
-        verbose_name = _('Toulouse Maelis')
+        verbose_name = 'Toulouse Maelis'
 
     def get_client(self, wsdl_short_name):
         wsse = UsernameToken(self.zeep_wsse_username, self.zeep_wsse_password)
         wsdl_name = wsdl_short_name + 'Service?wsdl'
         wsdl_url = urljoin(self.base_wsdl_url, wsdl_name)
         return self.soap_client(wsdl_url=wsdl_url, wsse=wsse)
 
     def call(self, wsdl_short_name, service, **kwargs):
@@ -157,44 +155,44 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         '''send null fields as empty SOAP tag to tell maelis to empty the value'''
         for key, value in dico.items():
             if isinstance(value, dict):
                 self.replace_null_values(value)
             if value is None:
                 dico[key] = ''
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Liste des catégories',
         name='read-category-list',
         perm='can_access',
     )
     def read_category_list(self, request):
         return {'data': self.get_referential('Category')['list']}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Liste des civilités',
         name='read-civility-list',
         perm='can_access',
     )
     def read_civility_list(self, request):
         return {'data': self.get_referential('Civility')['list']}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Liste des compléments du numéro de voie',
         name='read-complement-list',
         perm='can_access',
     )
     def read_complement_list(self, request):
         return {'data': self.get_referential('Complement')['list']}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='liste des catégories socio-professionnelles',
         name='read-csp-list',
         perm='can_access',
     )
     def read_csp_list(self, request):
         data = self.get_referential('CSP')['list']
 
         # remove redundant codes
@@ -203,115 +201,115 @@ class ToulouseMaelis(BaseResource, HTTPResource):
         for item in data:
             item['text'] = item['text'].strip()
             if item['text'] not in uniq_text:
                 uniq_data.append(item)
                 uniq_text.add(item['text'])
         return {'data': uniq_data}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='liste des qualités du référenciel',
         name='read-quality-list',
         perm='can_access',
     )
     def read_quality_list(self, request):
         return {'data': self.get_referential('Quality')['list']}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Liste des sexes',
         name='read-sex-list',
         perm='can_access',
     )
     def read_sex_list(self, request):
         return {'data': self.get_referential('Sex')['list']}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='liste des situations',
         name='read-situation-list',
         perm='can_access',
     )
     def read_situation_list(self, request):
         return {'data': self.get_referential('Situation')['list']}
 
     @endpoint(
-        display_category=_('Family'),
-        description=_('Create link between user and family'),
+        display_category='Famille',
+        description='Lier un compte usager à une famille',
         perm='can_access',
-        parameters={'NameID': {'description': _('Publik ID')}},
+        parameters={'NameID': {'description': 'Publik NameID'}},
         post={'request_body': {'schema': {'application/json': schemas.LINK_SCHEMA}}},
     )
     def link(self, request, NameID, post_data):
         family_id = post_data['family_id']
         response = self.call('Family', 'readFamily', dossierNumber=family_id)
         if not (
             response['RL1']['firstname'] == post_data['firstname'].upper()
             and response['RL1']['lastname'] == post_data['lastname'].upper()
             and response['RL1']['dateBirth'].strftime('%Y-%m-%d') == post_data['dateBirth']
         ):
             raise APIError("RL1 does not match '%s' family" % family_id, err_code='not-found')
         Link.objects.update_or_create(resource=self, name_id=NameID, defaults={'family_id': family_id})
         return {'data': 'ok'}
 
     @endpoint(
-        display_category=_('Family'),
-        description=_('Delete link between user and family'),
+        display_category='Famille',
+        description='Supprimer une liaison entre un compte usager et une famille',
         methods=['post'],
         perm='can_access',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
         },
     )
     def unlink(self, request, NameID):
         link = self.get_link(NameID)
         link.delete()
         return {'data': 'ok'}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Informations sur la famille',
         perm='can_access',
         name='read-family',
-        parameters={'NameID': {'description': _('Publik ID')}},
+        parameters={'NameID': {'description': 'Publik NameID'}},
     )
     def read_family(self, request, NameID):
         family_id = self.get_link(NameID).family_id
         data = self.get_family(family_id)
         return {'data': data}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Informations sur un responsable légal",
         perm='can_access',
         name='read-rl',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'rl_id': {'description': 'Numéro du représentant légal'},
         },
     )
     def read_rl(self, request, NameID, rl_id):
         family_id = self.get_link(NameID).family_id
         data = self.get_family(family_id)
         if data['RL1']['num'] == rl_id:
             data = data['RL1']
         elif data['RL2'] and data['RL2']['num'] == rl_id:
             data = data['RL2']
         else:
             raise APIError("no '%s' RL on '%s' family" % (rl_id, family_id), err_code='not-found')
         return {'data': data}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Informations sur une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
         perm='can_access',
         name='read-person',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'person_id': {'description': 'Numéro de la personne'},
             'kind': {'description': "'authorized' (par defaut) ou 'emergency'"},
         },
     )
     def read_person(self, request, NameID, person_id, kind='authorized'):
         if kind not in ('authorized', 'emergency'):
             raise APIError("wrong '%s' value for kind parameter" % kind)
         family_id = self.get_link(NameID).family_id
@@ -321,63 +319,63 @@ class ToulouseMaelis(BaseResource, HTTPResource):
                 break
         else:
             raise APIError(
                 "no '%s' %s person on '%s' family" % (person_id, kind, family_id), err_code='not-found'
             )
         return {'data': person}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Informations sur un enfant",
         perm='can_access',
         name='read-child',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'child_id': {'description': "Numéro de l'enfant"},
         },
     )
     def read_child(self, request, NameID, child_id):
         family_id = self.get_link(NameID).family_id
         data = self.get_family(family_id)
         for child in data['childList']:
             if child['num'] == child_id:
                 break
         else:
             raise APIError("no '%s' child on '%s' family" % (child_id, family_id), err_code='not-found')
         return {'data': child}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Vérifier qu'un responsable légal existe en base",
         perm='can_access',
         name='is-rl-exists',
         post={'request_body': {'schema': {'application/json': schemas.ISEXISTS_SCHEMA}}},
     )
     def is_rl_exists(self, request, post_data):
         response = self.call('Family', 'isRLExists', **post_data)
         return {'data': response}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Vérifier qu'un responsable légal existe en base",
         perm='can_access',
         name='is-child-exists',
         post={'request_body': {'schema': {'application/json': schemas.ISEXISTS_SCHEMA}}},
     )
     def is_child_exists(self, request, post_data):
         response = self.call('Family', 'isChildExists', **post_data)
         return {'data': response}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Création de la famille',
         name='create-family',
         perm='can_access',
-        parameters={'NameID': {'description': _('Publik ID')}},
+        parameters={'NameID': {'description': 'Publik NameID'}},
         post={'request_body': {'schema': {'application/json': schemas.CREATE_FAMILY_SCHEMA}}},
     )
     def create_family(self, request, NameID, post_data):
         if self.link_set.filter(name_id=NameID).exists():
             raise APIError('User already linked to family', err_code='already-linked')
 
         response = self.call('Family', 'createFamily', **post_data)
         data = serialize_object(response)
@@ -386,61 +384,61 @@ class ToulouseMaelis(BaseResource, HTTPResource):
             errors = data.get('rl1ErrorList') + data.get('childErrorList')
             err_codes = [x.split(':')[0][:4] for x in errors]
             raise APIError(' ; '.join(errors), err_code=', '.join(err_codes))
 
         Link.objects.create(resource=self, name_id=NameID, family_id=family_id)
         return {'data': data}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description='Modification de la famille',
         name='update-family',
         perm='can_access',
-        parameters={'NameID': {'description': _('Publik ID')}},
+        parameters={'NameID': {'description': 'Publik NameID'}},
         post={'request_body': {'schema': {'application/json': schemas.UPDATE_FAMILY_SCHEMA}}},
     )
     def update_family(self, request, NameID, post_data):
         family_id = self.get_link(NameID).family_id
         self.replace_null_values(post_data)
 
         response = self.call('Family', 'updateFamily', dossierNumber=family_id, **post_data)
         data = serialize_object(response)
         family_id = data.get('number')
         if not family_id:
             errors = data.get('rl1ErrorList') + data.get('childErrorList')
             err_codes = [x.split(':')[0][:4] for x in errors]
             raise APIError(' ; '.join(errors), err_code=', '.join(err_codes))
         return {'data': data}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Mise à jour des coordonnées d'une personne",
         name='update-coordinate',
         perm='can_access',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'rl_id': {'description': 'Numéro du représentant légal'},
         },
         post={'request_body': {'schema': {'application/json': schemas.UPDATE_COORDINATE_SCHEMA}}},
     )
     def update_coordinate(self, request, NameID, rl_id, post_data):
         family_id = self.get_link(NameID).family_id
         self.replace_null_values(post_data)
 
         self.call('Family', 'updateCoordinate', numDossier=family_id, numPerson=rl_id, **post_data)
         return {'data': 'ok'}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Création d'une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
         name='create-person',
         perm='can_access',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'kind': {'description': "'authorized' (par defaut) ou 'emergency'"},
         },
         post={'request_body': {'schema': {'application/json': schemas.FAMILYPERSON_SCHEMA}}},
     )
     def create_person(self, request, NameID, post_data, kind='authorized'):
         if kind not in ('authorized', 'emergency'):
             raise APIError("wrong '%s' value for kind parameter" % kind)
         family_id = self.get_link(NameID).family_id
@@ -454,22 +452,22 @@ class ToulouseMaelis(BaseResource, HTTPResource):
             'categorie': family['category'],
             'situation': family['situation'],
             kind + 'PersonList': [{'personList': personList}],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Mise à jour d'une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
         name='update-person',
         perm='can_access',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'person_id': {'description': 'Numéro de la personne'},
             'kind': {'description': "'authorized' (par defaut) ou 'emergency'"},
         },
         post={'request_body': {'schema': {'application/json': schemas.FAMILYPERSON_SCHEMA}}},
     )
     def update_person(self, request, NameID, person_id, post_data, kind='authorized'):
         if kind not in ('authorized', 'emergency'):
             raise APIError("wrong '%s' value for kind parameter" % kind)
@@ -492,22 +490,22 @@ class ToulouseMaelis(BaseResource, HTTPResource):
             'categorie': family['category'],
             'situation': family['situation'],
             kind + 'PersonList': [{'personList': personList}],
         }
         self.call('Family', 'updateFamily', **payload)
         return {'data': 'ok'}
 
     @endpoint(
-        display_category=_('Family'),
+        display_category='Famille',
         description="Suppression d'une personne autorisée à récupérer les enfants ou à prévenir en cas d'urgence",
         name='delete-person',
         perm='can_access',
         parameters={
-            'NameID': {'description': _('Publik ID')},
+            'NameID': {'description': 'Publik NameID'},
             'person_id': {'description': 'Numéro de la personne'},
             'kind': {'description': "'authorized' (par defaut) ou 'emergency'"},
         },
         methods=['post'],
     )
     def delete_person(self, request, NameID, person_id, kind='authorized'):
         if kind not in ('authorized', 'emergency'):
             raise APIError("wrong '%s' value for kind parameter" % kind)
-- 
2.30.2

