toulouse-maelis: add endpoint to create nursery demand (#73926)
gitea-wip/passerelle/pipeline/pr-main This commit looks good
Details
gitea-wip/passerelle/pipeline/pr-main This commit looks good
Details
This commit is contained in:
parent
cdc3071805
commit
feb5afc99b
|
@ -141,7 +141,7 @@ BIRTH_SCHEMA = {
|
|||
|
||||
INDICATOR_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'Address',
|
||||
'title': 'Indicator',
|
||||
'description': 'Indicateurs',
|
||||
'type': 'object',
|
||||
'required': ['code', 'isActive'],
|
||||
|
@ -937,3 +937,189 @@ SCHOOL_PRE_REGISTRATION_WITH_SIBLING_SCHEMA = {
|
|||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
NURSERY_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'Nursery',
|
||||
'description': 'Crèche',
|
||||
'type': 'object',
|
||||
'required': ['idActivity', 'idUnit', 'idPlace'],
|
||||
'properties': {
|
||||
'idActivity': {
|
||||
'description': 'Identifiant d\'activité',
|
||||
'type': 'string',
|
||||
},
|
||||
'idUnit': {
|
||||
'description': 'Identifiant unité',
|
||||
'type': 'string',
|
||||
},
|
||||
'idPlace': {
|
||||
'description': 'Identifiant lieu',
|
||||
'type': 'string',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
NURSERY_DEMAND_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'Nursery demand',
|
||||
'description': 'Crée une demande de place en crèche',
|
||||
'type': 'object',
|
||||
'required': ['family_id', 'start_date'],
|
||||
'properties': {
|
||||
'family_id': {
|
||||
'description': 'Numéro DUI',
|
||||
'type': 'string',
|
||||
},
|
||||
'family_indicators': {
|
||||
'oneOf': [
|
||||
{
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
}
|
||||
],
|
||||
'description': 'Liste des indicateurs à positionner sur la famille',
|
||||
},
|
||||
'child_id': {
|
||||
'description': 'Identifiant de l\'enfant',
|
||||
'type': 'string',
|
||||
},
|
||||
'child_first_name': {
|
||||
'description': 'Prénom de l\'enfant',
|
||||
'type': 'string',
|
||||
},
|
||||
'child_last_name': {
|
||||
'description': 'Nom de l\'enfant',
|
||||
'type': 'string',
|
||||
},
|
||||
'child_gender': {
|
||||
'description': 'Sexe de l\'enfant',
|
||||
'type': 'string',
|
||||
},
|
||||
'child_birthdate': {
|
||||
'description': 'Date de naissance ou date de naissance prévisionnelle de l\'enfant',
|
||||
'type': 'string',
|
||||
},
|
||||
'child_indicators': {
|
||||
'oneOf': [
|
||||
{
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
}
|
||||
],
|
||||
'description': 'Liste des indicateurs à positionner sur l\'enfant',
|
||||
},
|
||||
'demand_indicators': {
|
||||
'oneOf': [
|
||||
{
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
}
|
||||
],
|
||||
'description': 'Liste des indicateurs à positionner sur la demande',
|
||||
},
|
||||
'start_date': {
|
||||
'description': 'Date d\'entrée en structure souhaitée',
|
||||
'type': 'string',
|
||||
'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$',
|
||||
},
|
||||
'number_of_days': {
|
||||
'description': 'Nombre de jours par semaine',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-7]{1}$',
|
||||
},
|
||||
'start_hour_Mon': {
|
||||
'description': 'Heure de début le lundi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Mon': {
|
||||
'description': 'Heure de fin le lundi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Tue': {
|
||||
'description': 'Heure de début le mardi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Tue': {
|
||||
'description': 'Heure de fin le mardi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Wed': {
|
||||
'description': 'Heure de début le mercedi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Wed': {
|
||||
'description': 'Heure de fin le mercredi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Thu': {
|
||||
'description': 'Heure de début le jeudi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Thu': {
|
||||
'description': 'Heure de fin le jeudi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Fri': {
|
||||
'description': 'Heure de début le vendredi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Fri': {
|
||||
'description': 'Heure de fin le vendredi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Sat': {
|
||||
'description': 'Heure de début le samedi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Sat': {
|
||||
'description': 'Heure de fin le samedi',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'start_hour_Sun': {
|
||||
'description': 'Heure de début le dimanche',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'end_hour_Sun': {
|
||||
'description': 'Heure de fin le dimanche',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{2}:[0-9]{2}$',
|
||||
},
|
||||
'comment': {
|
||||
'description': 'Commentaire à propos du besoin d\'accueil',
|
||||
'type': 'string',
|
||||
},
|
||||
'accept_other_nurseries': {
|
||||
'description': 'Accepter d\'autres crèches',
|
||||
'oneOf': schemas.BOOLEAN_TYPES,
|
||||
},
|
||||
'nursery1': {
|
||||
'description': 'Premier choix de crèche',
|
||||
'oneOf': [NURSERY_SCHEMA],
|
||||
},
|
||||
'nursery2': {
|
||||
'description': 'Deuxième choix de crèche',
|
||||
'oneOf': [NURSERY_SCHEMA],
|
||||
},
|
||||
'nursery3': {
|
||||
'description': 'Troisième choix de crèche',
|
||||
'oneOf': [NURSERY_SCHEMA],
|
||||
},
|
||||
},
|
||||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
|
|
@ -2762,6 +2762,68 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
nurseries = [n for n in nurseries if code_psu in [u['typeAcc'] for u in n['unitList']]]
|
||||
return {'data': nurseries}
|
||||
|
||||
@endpoint(
|
||||
display_category='Inscriptions',
|
||||
description="Créer une demande de place en crèche pour un enfant",
|
||||
name='create-nursery-demand',
|
||||
perm='can_access',
|
||||
post={'request_body': {'schema': {'application/json': family_schemas.NURSERY_DEMAND_SCHEMA}}},
|
||||
)
|
||||
def create_nursery_demand(self, request, post_data):
|
||||
child_data = {}
|
||||
if post_data.get('child_id'):
|
||||
child_data['numPerson'] = post_data['child_id']
|
||||
else:
|
||||
child_data.update(
|
||||
{
|
||||
'firstname': post_data.get('child_first_name'),
|
||||
'lastname': post_data.get('child_last_name'),
|
||||
'sexe': post_data.get('child_gender'),
|
||||
'birth': {'dateBirth': post_data.get('child_birthdate')},
|
||||
}
|
||||
)
|
||||
if post_data.get('child_indicators'):
|
||||
child_data['indiPersList'] = post_data['child_indicators']
|
||||
|
||||
book_data = {'dateDepot': now().strftime(utils.json_date_format), 'datStart': post_data['start_date']}
|
||||
|
||||
if post_data.get('number_of_days'):
|
||||
book_data['nbDayByWeek'] = post_data.get('number_of_days')
|
||||
|
||||
for day in ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'):
|
||||
if post_data.get('start_hour_%s' % day):
|
||||
book_data['startHour%s' % day] = post_data.get('start_hour_%s' % day)
|
||||
|
||||
if post_data.get('end_hour_%s' % day):
|
||||
book_data['endHour%s' % day] = post_data.get('end_hour_%s' % day)
|
||||
|
||||
if 'accept_other_nurseries' in post_data:
|
||||
book_data['isAcceptOtherNursery'] = bool(post_data['accept_other_nurseries'])
|
||||
|
||||
if post_data.get('comment'):
|
||||
book_data['description'] = post_data['comment']
|
||||
|
||||
if post_data.get('comment'):
|
||||
book_data['description'] = post_data['comment']
|
||||
|
||||
if post_data.get('demand_indicators'):
|
||||
book_data['indiResapeList'] = post_data['demand_indicators']
|
||||
|
||||
for i in range(1, 4):
|
||||
if post_data.get('nursery%i' % i):
|
||||
book_data['choice%s' % i] = post_data['nursery%s' % i]
|
||||
|
||||
data = {
|
||||
'numDossier': post_data['family_id'],
|
||||
'child': child_data,
|
||||
'apeBook': book_data,
|
||||
}
|
||||
|
||||
if post_data.get('family_indicators'):
|
||||
data['indiFamList'] = post_data['family_indicators']
|
||||
|
||||
return {'data': self.call('Ape', 'addApeBook', request=data)}
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
|
|
|
@ -16,14 +16,88 @@
|
|||
<xs:complexType name="addApeBookRequestBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:all/>
|
||||
<xs:sequence>
|
||||
<xs:element name="numDossier" type="xs:int"/>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" name="indiFamList" nillable="true" type="tns:indicatorValueAddUpdBean"/>
|
||||
<xs:element name="child" type="tns:childAddUpdBean"/>
|
||||
<xs:element name="apeBook" type="tns:apeBookAddBean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="indicatorValueAddUpdBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:sequence>
|
||||
<xs:element name="code" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="note" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="choice" type="xs:string"/>
|
||||
<xs:element name="isActive" type="xs:boolean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="childAddUpdBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="numPerson" type="xs:int"/>
|
||||
<xs:element minOccurs="0" name="lastname" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="firstname" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="birth" type="ns1:birthInfoChildBean"/>
|
||||
<xs:element minOccurs="0" name="sexe" type="xs:string"/>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" name="indiPersList" nillable="true" type="tns:indicatorValueAddUpdBean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="apeBookAddBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:sequence>
|
||||
<xs:element name="dateDepot" type="xs:dateTime"/>
|
||||
<xs:element name="datStart" type="xs:dateTime"/>
|
||||
<xs:element minOccurs="0" name="nbDayByWeek" type="xs:float"/>
|
||||
<xs:element minOccurs="0" name="startHourMon" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourTue" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourWed" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourThu" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourFri" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourSat" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="startHourSun" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourMon" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourTue" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourWed" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourThu" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourFri" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourSat" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="endHourSun" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="description" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="choice1" type="tns:nurseryChoiceBean"/>
|
||||
<xs:element minOccurs="0" name="choice2" type="tns:nurseryChoiceBean"/>
|
||||
<xs:element minOccurs="0" name="choice3" type="tns:nurseryChoiceBean"/>
|
||||
<xs:element minOccurs="0" name="choice4" type="tns:nurseryChoiceBean"/>
|
||||
<xs:element minOccurs="0" name="isAcceptOtherNursery" type="xs:boolean"/>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" name="indiResapeList" nillable="true" type="tns:indicatorValueAddUpdBean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="nurseryChoiceBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecRequestBean">
|
||||
<xs:sequence>
|
||||
<xs:element name="idActivity" type="xs:string"/>
|
||||
<xs:element name="idUnit" type="xs:string"/>
|
||||
<xs:element name="idPlace" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="addApeBookResultBean">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecResultBean">
|
||||
<xs:sequence/>
|
||||
<xs:all/>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
@ -40,8 +114,8 @@
|
|||
<xs:complexContent>
|
||||
<xs:extension base="ns1:abstractSpecResultBean">
|
||||
<xs:sequence>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" name="indicatorList" nillable="true" type="tns:indicatorReadBean"/>
|
||||
<xs:element minOccurs="0" name="level" type="ns1:apeIndicatorLevelEnum"/>
|
||||
<xs:element maxOccurs="unbounded" minOccurs="0" name="indicatorList" nillable="true" type="tns:indicatorReadBean"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
|
@ -183,6 +257,14 @@
|
|||
<xs:complexType abstract="true" name="abstractSpecBean">
|
||||
<xs:sequence/>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="birthInfoChildBean">
|
||||
<xs:sequence>
|
||||
<xs:element name="dateBirth" type="xs:dateTime"/>
|
||||
<xs:element minOccurs="0" name="place" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="communeCode" type="xs:string"/>
|
||||
<xs:element minOccurs="0" name="countryCode" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="addApeBookResponse">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" name="result" type="ns1:addApeBookResultBean"/>
|
||||
|
@ -221,13 +303,6 @@
|
|||
<xs:element name="isWSRunning" type="xs:boolean"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="indicatorTypeDescEnum">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="NONE"/>
|
||||
<xs:enumeration value="NOTE"/>
|
||||
<xs:enumeration value="CHOICE"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="apeIndicatorLevelEnum">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="INDI_APE_FAM"/>
|
||||
|
@ -235,6 +310,13 @@
|
|||
<xs:enumeration value="INDI_APE_RES"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="indicatorTypeDescEnum">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="NONE"/>
|
||||
<xs:enumeration value="NOTE"/>
|
||||
<xs:enumeration value="CHOICE"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="nurseryTypeAccEnum">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="REGULAR"/>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:addApeBookResponse xmlns:ns2="ape.ws.maelis.sigec.com">
|
||||
<result/>
|
||||
</ns2:addApeBookResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -6138,3 +6138,37 @@ def test_read_nursery_list(con, app):
|
|||
|
||||
resp = app.get(url, params={'code_psu': 'REGULAR'})
|
||||
assert len(resp.json['data']) == 8
|
||||
|
||||
|
||||
def test_create_nursery_demand(ape_service, con, app):
|
||||
ape_service.add_soap_response('addApeBook', get_xml_file('R_create_nursery_demand.xml'))
|
||||
data = {
|
||||
'family_id': '322425',
|
||||
'accept_other_nurseries': False,
|
||||
'start_date': '2023-04-01',
|
||||
'child_first_name': 'Enfant',
|
||||
'child_last_name': 'nouveau né',
|
||||
'child_birthdate': '2022-11-01',
|
||||
'child_gender': 'G',
|
||||
'comment': 'Une place en crèche, svp',
|
||||
'number_of_days': '1',
|
||||
'child_indicators/0/code': 'APE_ALLO',
|
||||
'child_indicators/0/isActive': True,
|
||||
'child_indicators/1/code': 'code2',
|
||||
'child_indicators/1/isActive': False,
|
||||
'demand_indicators/0/code': 'APE_ALLO',
|
||||
'demand_indicators/0/isActive': True,
|
||||
'demand_indicators/1/code': 'APE_ALLO',
|
||||
'demand_indicators/1/isActive': False,
|
||||
'family_indicators/0/code': 'APE_ALLO',
|
||||
'family_indicators/0/isActive': False,
|
||||
'start_hour_Mon': '09:00',
|
||||
'end_hour_Mon': '18:00',
|
||||
'nursery1/idActivity': 'M10000000004',
|
||||
'nursery1/idUnit': 'M10053180335',
|
||||
'nursery1/idPlace': 'M10053180334',
|
||||
}
|
||||
|
||||
url = get_endpoint('create-nursery-demand')
|
||||
resp = app.post_json(url, params=data)
|
||||
assert resp.json['err'] == 0
|
||||
|
|
Loading…
Reference in New Issue