caluire-axel: new colors and restrictions for agenda (#55295)

This commit is contained in:
Lauréline Guérin 2021-07-02 16:50:06 +02:00
parent 3e86b98624
commit 38739c4fa5
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 32 additions and 26 deletions

View File

@ -623,23 +623,31 @@ class CaluireAxel(BaseResource):
'details': day,
}
color = 'grey'
if day['MATIN'] in ['X', 'H', 'R']:
if day['MATIN'] in ['X', 'R']:
color = 'green'
elif day['MATIN'] in ['H']:
color = 'yellow'
elif day['MATIN'] in ['.']:
color = 'white'
elif day['MATIN'] in ['D', 'C', 'M']:
color = 'orange' if day_date < datetime.date.today() else 'white'
color = 'orange'
elif day['MATIN'] in ['A', 'N']:
color = 'red' if day_date < datetime.date.today() else 'white'
color = 'red'
booking['details']['status_color'] = color
if pivot_date is None or day_date < pivot_date:
# not bookable or it's too late to book
booking['details']['out_of_delay'] = True
booking['disabled'] = True
disabled = True
else:
booking['details']['out_of_delay'] = False
booking['disabled'] = True if day_date < datetime.date.today() or color == 'grey' else False
if color in ['grey', 'yellow', 'red']:
disabled = True
elif color == 'orange':
disabled = day['MATIN'] != 'D'
else:
disabled = False
booking['disabled'] = disabled
booking['details']['activity_id'] = activity_id
booking['details']['activity_type'] = activity_type
if activity_label:

View File

@ -1112,28 +1112,26 @@ def test_get_agenda_endpoint_prefill(app, resource, family_data, activities, val
@pytest.mark.parametrize(
'value, color_past, color_future, disabled_future',
'value, color, disabled_future',
[
['<MATIN>X</MATIN>', 'green', 'green', False],
['<MATIN>H</MATIN>', 'green', 'green', False],
['<MATIN>R</MATIN>', 'green', 'green', False],
['<MATIN/>', 'grey', 'grey', True],
['<MATIN></MATIN>', 'grey', 'grey', True],
['<MATIN>.</MATIN>', 'white', 'white', False],
['<MATIN>F</MATIN>', 'grey', 'grey', True],
['<MATIN>S</MATIN>', 'grey', 'grey', True],
['<MATIN>T</MATIN>', 'grey', 'grey', True],
['<MATIN>D</MATIN>', 'orange', 'white', False],
['<MATIN>C</MATIN>', 'orange', 'white', False],
['<MATIN>M</MATIN>', 'orange', 'white', False],
['<MATIN>A</MATIN>', 'red', 'white', False],
['<MATIN>N</MATIN>', 'red', 'white', False],
['<MATIN>Z</MATIN>', 'grey', 'grey', True], # unknown
['<MATIN>X</MATIN>', 'green', False],
['<MATIN>H</MATIN>', 'yellow', True],
['<MATIN>R</MATIN>', 'green', False],
['<MATIN/>', 'grey', True],
['<MATIN></MATIN>', 'grey', True],
['<MATIN>.</MATIN>', 'white', False],
['<MATIN>F</MATIN>', 'grey', True],
['<MATIN>S</MATIN>', 'grey', True],
['<MATIN>T</MATIN>', 'grey', True],
['<MATIN>D</MATIN>', 'orange', False],
['<MATIN>C</MATIN>', 'orange', True],
['<MATIN>M</MATIN>', 'orange', True],
['<MATIN>A</MATIN>', 'red', True],
['<MATIN>N</MATIN>', 'red', True],
['<MATIN>Z</MATIN>', 'grey', True], # unknown
],
)
def test_get_agenda_endpoint_status(
app, resource, family_data, activities, value, color_past, color_future, disabled_future
):
def test_get_agenda_endpoint_status(app, resource, family_data, activities, value, color, disabled_future):
Link.objects.create(resource=resource, name_id='yyy', family_id='XXX', person_id='42')
content = (
'''<PORTAIL>
@ -1163,7 +1161,7 @@ def test_get_agenda_endpoint_status(
resp = app.get(
'/caluire-axel/test/get_agenda?NameID=yyy&idpersonne=50632&activity_id=ELEM&start_date=2020-09-01&end_date=2021-08-31'
)
assert resp.json['data'][0]['details']['status_color'] == color_past
assert resp.json['data'][0]['details']['status_color'] == color
assert resp.json['data'][0]['disabled'] is True
assert resp.json['data'][0]['details']['out_of_delay'] is True
@ -1171,7 +1169,7 @@ def test_get_agenda_endpoint_status(
resp = app.get(
'/caluire-axel/test/get_agenda?NameID=yyy&idpersonne=50632&activity_id=ELEM&start_date=2020-09-01&end_date=2021-08-31'
)
assert resp.json['data'][0]['details']['status_color'] == color_future
assert resp.json['data'][0]['details']['status_color'] == color
assert resp.json['data'][0]['disabled'] == disabled_future
assert resp.json['data'][0]['details']['out_of_delay'] is False