maelis: hide past units from child_activities endpoint (#50149)
This commit is contained in:
parent
7a3d1a92f3
commit
b75fcea27d
|
@ -447,7 +447,7 @@ class Maelis(BaseResource):
|
|||
activities = self.get_child_activities(childID, school_year, start_date, end_date)
|
||||
flatted_activities = utils.flatten_activities(activities, start_date, end_date)
|
||||
utils.mark_subscribed_flatted_activities(flatted_activities, child_info)
|
||||
data = utils.flatted_activities_as_list(flatted_activities, subscribingStatus)
|
||||
data = utils.flatted_activities_as_list(flatted_activities, subscribingStatus, start_date)
|
||||
return {'data': data}
|
||||
|
||||
@endpoint(
|
||||
|
|
|
@ -339,13 +339,15 @@ def mark_subscribed_flatted_activities(flatted_activities, child_info):
|
|||
place['unsubscribe_start_date'] = child_unit['dateStart']
|
||||
|
||||
|
||||
def flatted_activities_as_list(flatted_activities, filtering_status):
|
||||
def flatted_activities_as_list(flatted_activities, filtering_status, query_date):
|
||||
data = []
|
||||
for activity in [a[1] for a in sorted(flatted_activities.items())]:
|
||||
for unit in [u[1] for u in sorted(activity['units'].items())]:
|
||||
unit_info = unit['info']
|
||||
if unit_info['unit_object']['subscribePublication'] != 'E':
|
||||
continue
|
||||
if query_date > unit_info['unit_end_date'].date():
|
||||
continue
|
||||
is_unit_subscribed = False
|
||||
for place in unit['places'].values():
|
||||
if place.get('user_subscribing_status'):
|
||||
|
|
|
@ -2122,368 +2122,6 @@
|
|||
},
|
||||
"activity_text": "Alsh vacances mistral (capa)",
|
||||
"activity_weekly_planning_mask": "0000011",
|
||||
"id": "A10003131850-A10003131879-A10002132200",
|
||||
"place_id": "A10002132200",
|
||||
"place_object": {
|
||||
"activityPeriscolList": [],
|
||||
"adresse": {
|
||||
"idStreet": null,
|
||||
"num": 0,
|
||||
"street1": null,
|
||||
"street2": null,
|
||||
"town": "LA VALETTE-DU-VAR",
|
||||
"zipcode": "83160"
|
||||
},
|
||||
"id": "A10002132200",
|
||||
"lib": "ALSH MISTRAL",
|
||||
"lib2": null
|
||||
},
|
||||
"place_text": "Alsh Mistral",
|
||||
"subscribe_end_date": "2020-10-30T00:00:00+01:00",
|
||||
"subscribe_start_date": "2020-10-26T00:00:00+01:00",
|
||||
"text": "Alsh vacances mistral (capa) / Toussaint 2eme semaine / Alsh Mistral",
|
||||
"text_first_part": "Alsh vacances mistral (capa) / Toussaint 2eme semaine",
|
||||
"text_legacy": "2020-2021 ALSH VACANCES MISTRAL (CAPA) / TOUSSAINT 2EME SEMAINE / ALSH MISTRAL",
|
||||
"unit_calendar_letter": "D",
|
||||
"unit_id": "A10003131879",
|
||||
"unit_object": {
|
||||
"birthDateEnd": null,
|
||||
"birthDateStart": null,
|
||||
"calendList": [],
|
||||
"calendarLetter": "D",
|
||||
"calendarPublication": "N",
|
||||
"codeExt": null,
|
||||
"dateEnd": "2020-10-30T00:00:00+01:00",
|
||||
"dateEndSubscribe": "2020-10-30T00:00:00+01:00",
|
||||
"dateStart": "2020-10-26T00:00:00+01:00",
|
||||
"dateStartSubscribe": "2020-07-01T00:00:00+01:00",
|
||||
"idUnit": "A10003131879",
|
||||
"label": "TOUSSAINT 2EME SEMAINE",
|
||||
"numOrder": 2,
|
||||
"periodList": [],
|
||||
"recordAbsence": "O",
|
||||
"subscribePublication": "E"
|
||||
},
|
||||
"unit_text": "Toussaint 2eme semaine",
|
||||
"unit_weekly_planning": "DDDDD11",
|
||||
"user_subscribing_status": "not-subscribed"
|
||||
},
|
||||
{
|
||||
"activity_id": "A10003131850",
|
||||
"activity_object": {
|
||||
"activityPortail": {
|
||||
"activityBusList": [
|
||||
{
|
||||
"activity": {
|
||||
"id": "A10003151396",
|
||||
"label": "2020-2021 TRANSPORT ALSH"
|
||||
},
|
||||
"unitList": [
|
||||
{
|
||||
"idUnit": "A10003151403",
|
||||
"label": "Ligne MISTRAL / Retour",
|
||||
"placeList": [
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144173",
|
||||
"lib": "ARRET 1",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144174",
|
||||
"lib": "ARRET 2",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144175",
|
||||
"lib": "ARRET 3",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144176",
|
||||
"lib": "ARRET 4",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144177",
|
||||
"lib": "ARRET 5",
|
||||
"lib2": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"idUnit": "A10003151402",
|
||||
"label": "Ligne MISTRAL/ Aller",
|
||||
"placeList": [
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144173",
|
||||
"lib": "ARRET 1",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144174",
|
||||
"lib": "ARRET 2",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144175",
|
||||
"lib": "ARRET 3",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144176",
|
||||
"lib": "ARRET 4",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144177",
|
||||
"lib": "ARRET 5",
|
||||
"lib2": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"activityPeriodList": [],
|
||||
"activityType": {
|
||||
"code": "LOIVAC",
|
||||
"libelle": "(Loisirs Vacances)",
|
||||
"natureSpec": {
|
||||
"code": "L",
|
||||
"libelle": "Loisirs/Vacances"
|
||||
}
|
||||
},
|
||||
"birthControl": "N",
|
||||
"calendarGeneration": {
|
||||
"code": "NOT_REQUIRED",
|
||||
"value": "F"
|
||||
},
|
||||
"calendarMode": "N",
|
||||
"code": null,
|
||||
"dateEnd": "2021-07-02T00:00:00+01:00",
|
||||
"dateEndPubli": "2021-08-31T11:16:21+01:00",
|
||||
"dateStart": "2020-07-01T00:00:00+01:00",
|
||||
"dateStartPubli": "2020-07-01T11:16:21+01:00",
|
||||
"email": null,
|
||||
"idAct": "A10003131850",
|
||||
"label": "2020-2021 ALSH VACANCES MISTRAL (CAPA)",
|
||||
"schoolControl": null,
|
||||
"schoolYear": 2020,
|
||||
"weeklyCalendarActivityList": [
|
||||
{
|
||||
"weeklyCalendarStr": "0000011",
|
||||
"yearCalendar": 2020
|
||||
},
|
||||
{
|
||||
"weeklyCalendarStr": "0000011",
|
||||
"yearCalendar": 2021
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"activity_text": "Alsh vacances mistral (capa)",
|
||||
"activity_weekly_planning_mask": "0000011",
|
||||
"id": "A10003131850-A10003131882-A10002132200",
|
||||
"place_id": "A10002132200",
|
||||
"place_object": {
|
||||
"activityPeriscolList": [],
|
||||
"adresse": {
|
||||
"idStreet": null,
|
||||
"num": 0,
|
||||
"street1": null,
|
||||
"street2": null,
|
||||
"town": "LA VALETTE-DU-VAR",
|
||||
"zipcode": "83160"
|
||||
},
|
||||
"id": "A10002132200",
|
||||
"lib": "ALSH MISTRAL",
|
||||
"lib2": null
|
||||
},
|
||||
"place_text": "Alsh Mistral",
|
||||
"subscribe_end_date": "2020-10-23T00:00:00+01:00",
|
||||
"subscribe_start_date": "2020-10-19T00:00:00+01:00",
|
||||
"text": "Alsh vacances mistral (capa) / Toussaint 1 ere semaine / Alsh Mistral",
|
||||
"text_first_part": "Alsh vacances mistral (capa) / Toussaint 1 ere semaine",
|
||||
"text_legacy": "2020-2021 ALSH VACANCES MISTRAL (CAPA) / TOUSSAINT 1 ERE SEMAINE / ALSH MISTRAL",
|
||||
"unit_calendar_letter": "C",
|
||||
"unit_id": "A10003131882",
|
||||
"unit_object": {
|
||||
"birthDateEnd": null,
|
||||
"birthDateStart": null,
|
||||
"calendList": [],
|
||||
"calendarLetter": "C",
|
||||
"calendarPublication": "N",
|
||||
"codeExt": null,
|
||||
"dateEnd": "2020-10-23T00:00:00+01:00",
|
||||
"dateEndSubscribe": "2020-10-30T00:00:00+01:00",
|
||||
"dateStart": "2020-10-19T00:00:00+01:00",
|
||||
"dateStartSubscribe": "2020-07-01T07:20:00+01:00",
|
||||
"idUnit": "A10003131882",
|
||||
"label": "TOUSSAINT 1 ERE SEMAINE",
|
||||
"numOrder": 1,
|
||||
"periodList": [],
|
||||
"recordAbsence": "N",
|
||||
"subscribePublication": "E"
|
||||
},
|
||||
"unit_text": "Toussaint 1 ere semaine",
|
||||
"unit_weekly_planning": "CCCCC11",
|
||||
"user_subscribing_status": "not-subscribed"
|
||||
},
|
||||
{
|
||||
"activity_id": "A10003131850",
|
||||
"activity_object": {
|
||||
"activityPortail": {
|
||||
"activityBusList": [
|
||||
{
|
||||
"activity": {
|
||||
"id": "A10003151396",
|
||||
"label": "2020-2021 TRANSPORT ALSH"
|
||||
},
|
||||
"unitList": [
|
||||
{
|
||||
"idUnit": "A10003151403",
|
||||
"label": "Ligne MISTRAL / Retour",
|
||||
"placeList": [
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144173",
|
||||
"lib": "ARRET 1",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144174",
|
||||
"lib": "ARRET 2",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144175",
|
||||
"lib": "ARRET 3",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144176",
|
||||
"lib": "ARRET 4",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144177",
|
||||
"lib": "ARRET 5",
|
||||
"lib2": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"idUnit": "A10003151402",
|
||||
"label": "Ligne MISTRAL/ Aller",
|
||||
"placeList": [
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144173",
|
||||
"lib": "ARRET 1",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144174",
|
||||
"lib": "ARRET 2",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144175",
|
||||
"lib": "ARRET 3",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144176",
|
||||
"lib": "ARRET 4",
|
||||
"lib2": null
|
||||
},
|
||||
{
|
||||
"activityPeriscolList": [],
|
||||
"adresse": null,
|
||||
"id": "A10003144177",
|
||||
"lib": "ARRET 5",
|
||||
"lib2": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"activityPeriodList": [],
|
||||
"activityType": {
|
||||
"code": "LOIVAC",
|
||||
"libelle": "(Loisirs Vacances)",
|
||||
"natureSpec": {
|
||||
"code": "L",
|
||||
"libelle": "Loisirs/Vacances"
|
||||
}
|
||||
},
|
||||
"birthControl": "N",
|
||||
"calendarGeneration": {
|
||||
"code": "NOT_REQUIRED",
|
||||
"value": "F"
|
||||
},
|
||||
"calendarMode": "N",
|
||||
"code": null,
|
||||
"dateEnd": "2021-07-02T00:00:00+01:00",
|
||||
"dateEndPubli": "2021-08-31T11:16:21+01:00",
|
||||
"dateStart": "2020-07-01T00:00:00+01:00",
|
||||
"dateStartPubli": "2020-07-01T11:16:21+01:00",
|
||||
"email": null,
|
||||
"idAct": "A10003131850",
|
||||
"label": "2020-2021 ALSH VACANCES MISTRAL (CAPA)",
|
||||
"schoolControl": null,
|
||||
"schoolYear": 2020,
|
||||
"weeklyCalendarActivityList": [
|
||||
{
|
||||
"weeklyCalendarStr": "0000011",
|
||||
"yearCalendar": 2020
|
||||
},
|
||||
{
|
||||
"weeklyCalendarStr": "0000011",
|
||||
"yearCalendar": 2021
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"activity_text": "Alsh vacances mistral (capa)",
|
||||
"activity_weekly_planning_mask": "0000011",
|
||||
"id": "A10003131850-A10003131885-A10002132200",
|
||||
"place_id": "A10002132200",
|
||||
"place_object": {
|
||||
|
|
|
@ -339,9 +339,9 @@ def test_get_child_planning(mocked_post, mocked_get, legacy, nb_events, nb_booke
|
|||
|
||||
|
||||
@pytest.mark.parametrize('parameters, nb_subscribed, nb_not_subscribed', [
|
||||
('&subscribingStatus=', 2, 20),
|
||||
('&subscribingStatus=', 2, 18),
|
||||
('&subscribingStatus=subscribed', 2, 0),
|
||||
('&subscribingStatus=not-subscribed', 0, 19),
|
||||
('&subscribingStatus=not-subscribed', 0, 17),
|
||||
])
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
|
|
Loading…
Reference in New Issue