manager: do not display shared custody slots after agenda date end (#71633)
This commit is contained in:
parent
57cb74a2ed
commit
c261233153
|
@ -18,7 +18,7 @@
|
|||
<tr>
|
||||
<th>{% trans "Week" %} {{ week }}</th>
|
||||
{% for slot in slots %}
|
||||
{% if slot.date < agenda.date_start %}
|
||||
{% if slot.date < agenda.date_start or agenda.date_end and slot.date > agenda.date_end %}
|
||||
<td></td>
|
||||
{% else %}
|
||||
<td class="guardian {% if slot.guardian == agenda.first_guardian %}first-guardian{% else %}second-guardian{% endif %}">{{ slot }}</td>
|
||||
|
|
|
@ -216,7 +216,7 @@ def test_shared_custody_agenda_month_view(app, admin_user):
|
|||
|
||||
|
||||
@pytest.mark.freeze_time('2022-02-01 14:00') # Tuesday
|
||||
def test_shared_custody_agenda_month_view_date_start(app, admin_user):
|
||||
def test_shared_custody_agenda_month_view_dates(app, admin_user):
|
||||
father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe')
|
||||
mother = Person.objects.create(user_external_id='mother_id', first_name='Jane', last_name='Doe')
|
||||
child = Person.objects.create(user_external_id='child_id', first_name='James', last_name='Doe')
|
||||
|
@ -248,11 +248,24 @@ def test_shared_custody_agenda_month_view_date_start(app, admin_user):
|
|||
new_days = [x.text for x in resp.pyquery('tbody tr th span')]
|
||||
assert days == new_days
|
||||
|
||||
# custody for only one day
|
||||
agenda.date_end = datetime.date(2022, 2, 14)
|
||||
agenda.save()
|
||||
resp = app.get('/manage/shared-custody/%s/' % agenda.pk).follow()
|
||||
assert resp.text.count('<td></td>') == 34
|
||||
assert len([x.text for x in resp.pyquery('tbody tr td.guardian')]) == 1
|
||||
|
||||
# month before date_start
|
||||
resp = resp.click('←')
|
||||
assert resp.text.count('<td></td>') == 42
|
||||
assert len([x.text for x in resp.pyquery('tbody tr td.guardian')]) == 0
|
||||
|
||||
# month after date_end
|
||||
resp = app.get('/manage/shared-custody/%s/' % agenda.pk).follow()
|
||||
resp = resp.click('→')
|
||||
assert resp.text.count('<td></td>') == 35
|
||||
assert len([x.text for x in resp.pyquery('tbody tr td.guardian')]) == 0
|
||||
|
||||
|
||||
def test_shared_custody_agenda_month_view_queries(app, admin_user):
|
||||
father = Person.objects.create(user_external_id='father_id', first_name='John', last_name='Doe')
|
||||
|
|
Loading…
Reference in New Issue