caluire_axel: ignore DEC activities (#75355)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5c88cee83e
commit
6804b6695f
|
@ -568,6 +568,10 @@ class CaluireAxel(BaseResource):
|
|||
ignore_wednesday=False,
|
||||
ignore_weekend=False,
|
||||
):
|
||||
if activity_id.startswith('DEC'):
|
||||
# classe decouverte, ignore
|
||||
return []
|
||||
|
||||
data = {
|
||||
'IDENTINDIVIDU': child_id,
|
||||
'IDENTACTIVITE': activity_id,
|
||||
|
@ -885,8 +889,8 @@ class CaluireAxel(BaseResource):
|
|||
updated = []
|
||||
for activity in activities_data.get('ACTIVITE', []):
|
||||
activity_id = activity['IDENTACTIVITE']
|
||||
if activity_id.startswith('CJ'):
|
||||
# mercredi or vacances: not bookable
|
||||
if activity_id.startswith(('CJ', 'DEC')):
|
||||
# mercredi, vacances or classe decouverte: not bookable
|
||||
continue
|
||||
bookings = self.set_bookings(
|
||||
child_id,
|
||||
|
@ -1004,8 +1008,8 @@ class CaluireAxel(BaseResource):
|
|||
current_child_activity_ids = set()
|
||||
for activity in activities_data.get('ACTIVITE', []):
|
||||
activity_id = activity['IDENTACTIVITE']
|
||||
if activity_id.startswith('CJ'):
|
||||
# mercredi or vacances: not bookable
|
||||
if activity_id.startswith(('CJ', 'DEC')):
|
||||
# mercredi, vacances or classe decouverte: not bookable
|
||||
continue
|
||||
if self.get_activity_type(activity_id) == 'midi':
|
||||
current_child_cantine_activity_ids.append(activity_id)
|
||||
|
@ -1025,8 +1029,8 @@ class CaluireAxel(BaseResource):
|
|||
changes = {}
|
||||
for change in post_data['changes']:
|
||||
activity_id = change['activity_id']
|
||||
if activity_id.startswith('CJ'):
|
||||
# mercredi or vacances: not bookable
|
||||
if activity_id.startswith(('CJ', 'DEC')):
|
||||
# mercredi, vacances or classe decouverte: not bookable
|
||||
continue
|
||||
# activity_id can be different for cantine activity
|
||||
if self.get_activity_type(activity_id) == 'midi':
|
||||
|
@ -1079,7 +1083,7 @@ class CaluireAxel(BaseResource):
|
|||
if activity_data is None:
|
||||
raise APIError('Activity not found', err_code='not-found')
|
||||
|
||||
if activity_id.startswith('CJ'):
|
||||
if activity_id.startswith(('CJ', 'DEC')):
|
||||
raise APIError('Not available for this activity', err_code='bad-request', http_status=400)
|
||||
|
||||
booking_date = start_date
|
||||
|
|
|
@ -144,6 +144,12 @@ def activities_full():
|
|||
'IDENTACTIVITE': 'NAV SOIR',
|
||||
'LIBELLEACTIVITE': 'Navette du soir',
|
||||
},
|
||||
{
|
||||
'ENTREE': '2020-09-02',
|
||||
'SORTIE': '2021-08-31',
|
||||
'IDENTACTIVITE': 'DECFOO',
|
||||
'LIBELLEACTIVITE': 'Une classe découverte',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -1413,6 +1419,38 @@ def test_get_agenda_endpoint_delay_extrascolaire(
|
|||
assert resp.json['data'][0]['details']['activity_type'] == activity_type
|
||||
|
||||
|
||||
def test_get_agenda_endpoint_delay_class_decouverte(app, resource, family_data, activities_full):
|
||||
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
||||
content = '''<PORTAIL>
|
||||
<GETAGENDA>
|
||||
<CODE>1</CODE>
|
||||
<JOUR>
|
||||
<JOURDATE>12/07/2021</JOURDATE>
|
||||
<MATIN>X</MATIN>
|
||||
<MIDI></MIDI>
|
||||
<APRESMIDI></APRESMIDI>
|
||||
<FERME>N</FERME>
|
||||
</JOUR>
|
||||
</GETAGENDA>
|
||||
</PORTAIL>'''
|
||||
with mock_data(content, 'GetAgenda'):
|
||||
with mock.patch(
|
||||
'passerelle.contrib.caluire_axel.models.CaluireAxel.get_family_data',
|
||||
return_value=family_data,
|
||||
):
|
||||
with mock.patch(
|
||||
'passerelle.contrib.caluire_axel.models.CaluireAxel.get_child_activities',
|
||||
return_value=activities_full,
|
||||
):
|
||||
# always disabled
|
||||
with freezegun.freeze_time('2021-05-31'):
|
||||
resp = app.get(
|
||||
'/caluire-axel/test/get_agenda?NameID=yyy&idpersonne=50632&activity_id=%s&start_date=2021-06-02&end_date=2021-06-02'
|
||||
% 'DECFOO'
|
||||
)
|
||||
assert len(resp.json['data']) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('code', [0, -1, -2, -3, -4])
|
||||
def test_get_agenda_endpoint_wrong_code(app, resource, family_data, activities, code):
|
||||
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
||||
|
@ -2503,12 +2541,12 @@ def test_set_agenda_endpoint_prefill_periscolaire(
|
|||
@pytest.mark.parametrize('prefill', [True, False])
|
||||
@pytest.mark.parametrize('wanted', [True, False])
|
||||
@freezegun.freeze_time('2020-08-01')
|
||||
def test_set_agenda_endpoint_prefill_extrascolaire(
|
||||
def test_set_agenda_endpoint_prefill_extrascolaire_and_classe_decouverte(
|
||||
app, resource, family_data, booking_params, prefill, wanted
|
||||
):
|
||||
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
||||
booking_params['end_date'] = '2020-09-01'
|
||||
for activity_id in ['CJ MER', 'CJVACANCES']:
|
||||
for activity_id in ['CJ MER', 'CJVACANCES', 'DECFOO']:
|
||||
activity = {
|
||||
'ENTREE': '2020-09-02',
|
||||
'SORTIE': '2021-08-31',
|
||||
|
@ -2823,6 +2861,12 @@ def test_set_agenda_apply_changes_endpoint_multi(app, resource, family_data, cha
|
|||
'IDENTACTIVITE': 'CJVACANCES',
|
||||
'LIBELLEACTIVITE': 'FOOBAR',
|
||||
},
|
||||
{
|
||||
'ENTREE': '2020-09-02',
|
||||
'SORTIE': '2021-08-31',
|
||||
'IDENTACTIVITE': 'DECFOO',
|
||||
'LIBELLEACTIVITE': 'FOOBAR',
|
||||
},
|
||||
]
|
||||
changes_params['end_date'] = '2020-09-11'
|
||||
changes_params['changes'] = [
|
||||
|
@ -2847,6 +2891,12 @@ def test_set_agenda_apply_changes_endpoint_multi(app, resource, family_data, cha
|
|||
'day': '2020-09-08',
|
||||
'booked': True,
|
||||
}, # ignored
|
||||
{
|
||||
'activity_id': 'DECFOO',
|
||||
'activity_label': 'FOOBAR',
|
||||
'day': '2020-09-08',
|
||||
'booked': True,
|
||||
}, # ignored
|
||||
]
|
||||
bookings = []
|
||||
for activity_id in ['ACCMAT', 'ECOLELEM']:
|
||||
|
@ -3416,14 +3466,14 @@ def test_set_activity_agenda_typical_week_endpoint_prefill_periscolaire(
|
|||
|
||||
|
||||
@freezegun.freeze_time('2020-08-01')
|
||||
def test_set_activity_agenda_typical_week_endpoint_extrascolaire(
|
||||
def test_set_activity_agenda_typical_week_endpoint_extrascolaire_and_classe_decouverte(
|
||||
app,
|
||||
resource,
|
||||
family_data,
|
||||
week_booking_params,
|
||||
):
|
||||
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
|
||||
for activity_id in ['CJ MER', 'CJVACANCES']:
|
||||
for activity_id in ['CJ MER', 'CJVACANCES', 'DECFOO']:
|
||||
activity = {
|
||||
'ENTREE': '2020-09-02',
|
||||
'SORTIE': '2021-08-31',
|
||||
|
|
Loading…
Reference in New Issue