toulouse-maelis: ajouter un endpoint pour l'inscription sans panier (#74763) #160
|
@ -2945,27 +2945,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
response['agenda'] = bookings
|
||||
return {'data': response}
|
||||
|
||||
@endpoint(
|
||||
display_category='Inscriptions',
|
||||
description="Ajouter au panier une inscription extra-scolaire ou loisir",
|
||||
name='add-person-basket-subscription',
|
||||
perm='can_access',
|
||||
post={
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': activity_schemas.SUBSCRIPTION_SCHEMA,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
def add_person_basket_subscription(
|
||||
self,
|
||||
request,
|
||||
post_data,
|
||||
NameID=None,
|
||||
family_id=None,
|
||||
):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
def process_subscription_payload(self, family_id, post_data):
|
||||
params = {
|
||||
'numDossier': family_id,
|
||||
'numPerson': post_data['person_id'],
|
||||
|
@ -3007,6 +2987,30 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
'isPresent': True,
|
||||
}
|
||||
)
|
||||
return recurrent_week
|
||||
|
||||
@endpoint(
|
||||
display_category='Inscriptions',
|
||||
description="Ajouter au panier une inscription extra-scolaire ou loisir",
|
||||
name='add-person-basket-subscription',
|
||||
perm='can_access',
|
||||
post={
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': activity_schemas.SUBSCRIPTION_SCHEMA,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
def add_person_basket_subscription(
|
||||
self,
|
||||
request,
|
||||
post_data,
|
||||
NameID=None,
|
||||
family_id=None,
|
||||
):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
recurrent_week = self.process_subscription_payload(family_id, post_data)
|
||||
payload = {
|
||||
'addPersonUnitBasketRequestBean': {
|
||||
'numFamily': family_id,
|
||||
|
@ -3025,6 +3029,46 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
raise APIError(response['controlResult']['message'])
|
||||
return {'data': response}
|
||||
|
||||
@endpoint(
|
||||
display_category='Inscriptions',
|
||||
description="Ajouter une inscription extra-scolaire ou loisir",
|
||||
name='add-person-subscription',
|
||||
perm='can_access',
|
||||
post={
|
||||
'request_body': {
|
||||
'schema': {
|
||||
'application/json': activity_schemas.SUBSCRIPTION_SCHEMA,
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
def add_person_subscription(
|
||||
self,
|
||||
request,
|
||||
post_data,
|
||||
NameID=None,
|
||||
family_id=None,
|
||||
):
|
||||
family_id = family_id or self.get_link(NameID).family_id
|
||||
recurrent_week = self.process_subscription_payload(family_id, post_data)
|
||||
payload = {
|
||||
'AddPersonSubscribeRequestBean': {
|
||||
'numFamily': family_id,
|
||||
'numPerson': post_data['person_id'],
|
||||
'idAct': post_data['activity_id'],
|
||||
'idUnit': post_data['unit_id'],
|
||||
'idPlace': post_data['place_id'],
|
||||
'dateStartSubscribe': post_data['start_date'],
|
||||
'dateEndSubscribe': post_data['end_date'],
|
||||
'dayWeekInfoList': recurrent_week,
|
||||
'conveyanceSubscribe': post_data.get('conveyanceSubscribe'),
|
||||
}
|
||||
}
|
||||
response = self.call('Activity', 'addPersonUnitSubscribe', **payload)
|
||||
if not response['controlOK']:
|
||||
raise APIError(response['message'])
|
||||
return {'data': response}
|
||||
|
||||
def get_activity_bookings(self, family_id, person_id, activity_id, start_date, end_date):
|
||||
bookings = []
|
||||
for booking_date in rrule.rrule(rrule.MONTHLY, dtstart=start_date.replace(day=1), until=end_date):
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:addPersonUnitSubscribeResponse xmlns:ns2="activity.ws.maelis.sigec.com" xmlns:ns3="bean.persistence.activity.ws.maelis.sigec.com" xmlns:ns4="bean.persistence.school.ws.maelis.sigec.com">
|
||||
<addPersonUnitSubscribeResponseBean>
|
||||
<controlResult>
|
||||
<controlOK>true</controlOK>
|
||||
</controlResult>
|
||||
</addPersonUnitSubscribeResponseBean>
|
||||
</ns2:addPersonUnitSubscribeResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,12 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:addPersonUnitSubscribeResponse xmlns:ns2="activity.ws.maelis.sigec.com" xmlns:ns3="bean.persistence.activity.ws.maelis.sigec.com" xmlns:ns4="bean.persistence.school.ws.maelis.sigec.com">
|
||||
<addPersonUnitSubscribeResponseBean>
|
||||
<controlResult>
|
||||
<controlOK>false</controlOK>
|
||||
<message>E1019 : Il existe déjà une inscription à cette unité</message>
|
||||
</controlResult>
|
||||
</addPersonUnitSubscribeResponseBean>
|
||||
</ns2:addPersonUnitSubscribeResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -6952,6 +6952,140 @@ def test_add_person_basket_subscription_with_conveyance_not_found(activity_servi
|
|||
assert resp.json['err_desc'] == 'no "plop" place defined on "afternoonJourney" conveyance'
|
||||
|
||||
|
||||
def test_add_person_subscription(activity_service, con, app):
|
||||
activity_service.add_soap_response(
|
||||
'getPersonUnitInfo',
|
||||
get_xml_file('R_get_person_unit_info.xml'),
|
||||
)
|
||||
activity_service.add_soap_response(
|
||||
'addPersonUnitSubscribe',
|
||||
get_xml_file('R_add_person_unit_subscribe.xml'),
|
||||
)
|
||||
url = get_endpoint('add-person-subscription')
|
||||
|
||||
params = {
|
||||
'person_id': '246423',
|
||||
'activity_id': 'A10051141965',
|
||||
'unit_id': 'A10051141990',
|
||||
'place_id': 'A10053179226',
|
||||
'start_date': '2022-09-01',
|
||||
'end_date': '2023-08-31',
|
||||
}
|
||||
resp = app.post_json(url + '?family_id=311323', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
Link.objects.create(resource=con, family_id='311323', name_id='local')
|
||||
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == {'controlOK': True, 'message': None}
|
||||
|
||||
|
||||
def test_add_person_subscription_with_recurrent_week(activity_service, con, app):
|
||||
def request_check(request):
|
||||
assert serialize_object(request.dayWeekInfoList) == [
|
||||
{'dayNum': 1, 'isPresent': True, 'isOpen': None, 'calendarLetter': 'B'},
|
||||
{'dayNum': 2, 'isPresent': True, 'isOpen': None, 'calendarLetter': 'C'},
|
||||
]
|
||||
|
||||
activity_service.add_soap_response(
|
||||
'getPersonUnitInfo',
|
||||
get_xml_file('R_get_person_unit_info_with_conveyance.xml'),
|
||||
)
|
||||
activity_service.add_soap_response(
|
||||
'addPersonUnitSubscribe',
|
||||
get_xml_file('R_add_person_unit_subscribe.xml'),
|
||||
request_check=request_check,
|
||||
)
|
||||
url = get_endpoint('add-person-subscription')
|
||||
|
||||
params = {
|
||||
'person_id': '246423',
|
||||
'activity_id': 'A10051141965',
|
||||
'unit_id': 'A10051141990',
|
||||
'place_id': 'A10053179226',
|
||||
'start_date': '2022-09-01',
|
||||
'end_date': '2023-08-31',
|
||||
'recurrent_week': ['1-B', '2-C'],
|
||||
}
|
||||
resp = app.post_json(url + '?family_id=311323', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
Link.objects.create(resource=con, family_id='311323', name_id='local')
|
||||
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
|
||||
|
||||
def test_add_person_subscription_with_conveyance(activity_service, con, app):
|
||||
def request_check(request):
|
||||
assert serialize_object(request.conveyanceSubscribe) == {
|
||||
'idPlaceMorning': 'A10053179757',
|
||||
'idPlaceAfternoon': 'A10053179757',
|
||||
}
|
||||
|
||||
activity_service.add_soap_response(
|
||||
'getPersonUnitInfo',
|
||||
get_xml_file('R_get_person_unit_info_with_conveyance.xml'),
|
||||
)
|
||||
activity_service.add_soap_response(
|
||||
'addPersonUnitSubscribe',
|
||||
get_xml_file('R_add_person_unit_subscribe.xml'),
|
||||
request_check=request_check,
|
||||
)
|
||||
url = get_endpoint('add-person-subscription')
|
||||
|
||||
params = {
|
||||
'person_id': '261768',
|
||||
'activity_id': 'A10053179798',
|
||||
'unit_id': 'A10053179803',
|
||||
'place_id': 'A10053179757',
|
||||
'start_date': '2022-09-01',
|
||||
'end_date': '2023-08-31',
|
||||
'conveyanceSubscribe/idPlaceMorning': 'A10053179757',
|
||||
'conveyanceSubscribe/idPlaceAfternoon': 'A10053179757',
|
||||
}
|
||||
resp = app.post_json(url + '?family_id=322423', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
|
||||
|
||||
def test_add_person_subscription_not_linked_error(con, app):
|
||||
url = get_endpoint('add-person-subscription')
|
||||
params = {
|
||||
'person_id': '246423',
|
||||
'activity_id': 'A10051141965',
|
||||
'unit_id': 'A10051141990',
|
||||
'place_id': 'A10053179226',
|
||||
'start_date': '2022-09-01',
|
||||
'end_date': '2023-08-31',
|
||||
}
|
||||
resp = app.post_json(url + '?NameID=local', params=params)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
def test_add_person_subscription_error(activity_service, con, app):
|
||||
activity_service.add_soap_response(
|
||||
'getPersonUnitInfo',
|
||||
get_xml_file('R_get_person_unit_info.xml'),
|
||||
)
|
||||
activity_service.add_soap_response(
|
||||
'addPersonUnitSubscribe',
|
||||
get_xml_file('R_add_person_unit_subscribe_error.xml'),
|
||||
)
|
||||
url = get_endpoint('add-person-subscription')
|
||||
|
||||
params = {
|
||||
'person_id': '246423',
|
||||
'activity_id': 'A10051141965',
|
||||
'unit_id': 'A10051141990',
|
||||
'place_id': 'A10053179226',
|
||||
'start_date': '2022-09-01',
|
||||
'end_date': '2023-08-31',
|
||||
}
|
||||
resp = app.post_json(url + '?family_id=311323', params=params)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'E1019 : Il existe déjà une inscription à cette unité'
|
||||
|
||||
|
||||
def test_read_activity_agenda(activity_service, con, app):
|
||||
activity_service.add_soap_response(
|
||||
'getPersonScheduleList', get_xml_file('R_get_person_schedule_list_on_activity.xml')
|
||||
|
|
Loading…
Reference in New Issue