0001-manager-use-sidetabs-in-shared-custody-agenda-settin.patch
chrono/manager/templates/chrono/manager_shared_custody_agenda_settings.html | ||
---|---|---|
18 | 18 |
{% endblock %} |
19 | 19 | |
20 | 20 |
{% block content %} |
21 | ||
21 | 22 |
{% if not agenda.is_complete %} |
22 | 23 |
<div class="warningnotice"> |
23 | 24 |
<p>{% trans "Custody rules are not complete." %}</p> |
24 | 25 |
</div> |
25 | 26 |
{% endif %} |
26 |
<div class="section"> |
|
27 |
<h3>{% trans "Custody rules" %}</h3> |
|
28 |
<div> |
|
29 |
{% if agenda.rules.all %} |
|
30 |
<ul class="objects-list single-links"> |
|
31 |
{% for rule in agenda.rules.all %} |
|
32 |
<li><a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-rule' pk=agenda.pk rule_pk=rule.pk %}"> |
|
33 |
<span class="rule-info"> |
|
34 |
{{ rule.guardian }}, {{ rule.label }} |
|
35 |
</span> |
|
36 |
</a> |
|
37 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-rule' pk=agenda.pk rule_pk=rule.pk %}?next=settings">{% trans "remove" %}</a> |
|
38 |
</li> |
|
39 |
{% endfor %} |
|
40 |
</ul> |
|
41 |
{% else %} |
|
42 |
<div class="big-msg-info"> |
|
43 |
{% blocktrans trimmed %} |
|
44 |
This agenda doesn't have any custody rules yet. |
|
45 |
{% endblocktrans %} |
|
46 |
</div> |
|
27 | ||
28 |
<div class="section agenda-settings"> |
|
29 |
<div class="pk-tabs"> |
|
30 |
<div class="pk-tabs--tab-list" role="tablist"> |
|
31 |
<button aria-controls="panel-rules" aria-selected="true" id="tab-rules" role="tab" tabindex="0">{% trans "Custody rules" %}</button> |
|
32 |
{% if has_holidays %} |
|
33 |
<button aria-controls="panel-holidays" aria-selected="false" id="tab-holidays" role="tab" tabindex="-1">{% trans "Custody rules during holidays" %}</button> |
|
47 | 34 |
{% endif %} |
35 |
<button aria-controls="panel-time-periods" aria-selected="false" id="tab-time-periods" role="tab" tabindex="-1">{% trans "Exceptional custody periods" %}</button> |
|
48 | 36 |
</div> |
49 |
</div>
|
|
37 |
<div class="pk-tabs--container">
|
|
50 | 38 | |
51 |
{% if has_holidays %} |
|
52 |
<div class="section"> |
|
53 |
<h3>{% trans "Custody rules during holidays" %}</h3> |
|
54 |
<div> |
|
55 |
{% if agenda.holiday_rules.all %} |
|
56 |
<ul class="objects-list single-links"> |
|
57 |
{% for rule in agenda.holiday_rules.all %} |
|
58 |
<li><a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-holiday-rule' pk=agenda.pk rule_pk=rule.pk %}"> |
|
59 |
<span class="rule-info"> |
|
60 |
{{ rule.guardian }}, {{ rule.label }} |
|
61 |
</span> |
|
62 |
</a> |
|
63 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-holiday-rule' pk=agenda.pk rule_pk=rule.pk %}?next=settings">{% trans "remove" %}</a> |
|
64 |
</li> |
|
65 |
{% endfor %} |
|
66 |
</ul> |
|
67 |
{% else %} |
|
68 |
<div class="big-msg-info"> |
|
69 |
{% blocktrans trimmed %} |
|
70 |
This agenda doesn't specify any custody rules during holidays. It means normal rules will be applied. |
|
71 |
{% endblocktrans %} |
|
39 |
<div aria-labelledby="tab-rules" id="panel-rules" role="tabpanel" tabindex="0"> |
|
40 |
{% if agenda.rules.all %} |
|
41 |
<ul class="objects-list single-links"> |
|
42 |
{% for rule in agenda.rules.all %} |
|
43 |
<li><a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-rule' pk=agenda.pk rule_pk=rule.pk %}"> |
|
44 |
<span class="rule-info"> |
|
45 |
{{ rule.guardian }}, {{ rule.label }} |
|
46 |
</span> |
|
47 |
</a> |
|
48 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-rule' pk=agenda.pk rule_pk=rule.pk %}?next=settings">{% trans "remove" %}</a> |
|
49 |
</li> |
|
50 |
{% endfor %} |
|
51 |
</ul> |
|
52 |
{% else %} |
|
53 |
<div class="big-msg-info"> |
|
54 |
{% blocktrans trimmed %} |
|
55 |
This agenda doesn't have any custody rules yet. |
|
56 |
{% endblocktrans %} |
|
57 |
</div> |
|
58 |
{% endif %} |
|
72 | 59 |
</div> |
73 |
{% endif %} |
|
74 |
</div> |
|
75 |
</div> |
|
76 |
{% endif %} |
|
77 | 60 | |
78 |
<div class="section"> |
|
79 |
<h3>{% trans "Exceptional custody periods" %}</h3> |
|
80 |
<div> |
|
81 |
{% if exceptional_periods %} |
|
82 |
<ul class="objects-list single-links"> |
|
83 |
{% for period in exceptional_periods %} |
|
84 |
<li> |
|
85 |
<a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-period' pk=agenda.pk period_pk=period.pk %}"> |
|
86 |
{{ period }} |
|
87 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-period' pk=agenda.pk period_pk=period.pk %}?next=settings">{% trans "remove" %}</a> |
|
88 |
</a> |
|
89 |
</li> |
|
90 |
{% endfor %} |
|
91 |
</ul> |
|
92 |
{% else %} |
|
93 |
<div class="big-msg-info"> |
|
94 |
{% blocktrans trimmed %} |
|
95 |
This agenda doesn't have any custody period. They can be used to specify explicit moments when one of the guardian should have custody, regardless of global rules. |
|
96 |
{% endblocktrans %} |
|
61 |
{% if has_holidays %} |
|
62 |
<div aria-labelledby="tab-holidays" hidden="" id="panel-holidays" role="tabpanel" tabindex="0"> |
|
63 |
{% if agenda.holiday_rules.all %} |
|
64 |
<ul class="objects-list single-links"> |
|
65 |
{% for rule in agenda.holiday_rules.all %} |
|
66 |
<li><a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-holiday-rule' pk=agenda.pk rule_pk=rule.pk %}"> |
|
67 |
<span class="rule-info"> |
|
68 |
{{ rule.guardian }}, {{ rule.label }} |
|
69 |
</span> |
|
70 |
</a> |
|
71 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-holiday-rule' pk=agenda.pk rule_pk=rule.pk %}?next=settings">{% trans "remove" %}</a> |
|
72 |
</li> |
|
73 |
{% endfor %} |
|
74 |
</ul> |
|
75 |
{% else %} |
|
76 |
<div class="big-msg-info"> |
|
77 |
{% blocktrans trimmed %} |
|
78 |
This agenda doesn't specify any custody rules during holidays. It means normal rules will be applied. |
|
79 |
{% endblocktrans %} |
|
80 |
</div> |
|
81 |
{% endif %} |
|
97 | 82 |
</div> |
98 | 83 |
{% endif %} |
84 | ||
85 |
<div aria-labelledby="tab-time-periods" hidden="" id="panel-time-periods" role="tabpanel" tabindex="0"> |
|
86 |
{% if exceptional_periods %} |
|
87 |
<ul class="objects-list single-links"> |
|
88 |
{% for period in exceptional_periods %} |
|
89 |
<li> |
|
90 |
<a rel="popup" href="{% url 'chrono-manager-shared-custody-agenda-edit-period' pk=agenda.pk period_pk=period.pk %}"> |
|
91 |
{{ period }} |
|
92 |
<a rel="popup" class="delete" href="{% url 'chrono-manager-shared-custody-agenda-delete-period' pk=agenda.pk period_pk=period.pk %}?next=settings">{% trans "remove" %}</a> |
|
93 |
</a> |
|
94 |
</li> |
|
95 |
{% endfor %} |
|
96 |
</ul> |
|
97 |
{% else %} |
|
98 |
<div class="big-msg-info"> |
|
99 |
{% blocktrans trimmed %} |
|
100 |
This agenda doesn't have any custody period. They can be used to specify explicit moments when one of the guardian should have custody, regardless of global rules. |
|
101 |
{% endblocktrans %} |
|
102 |
</div> |
|
103 |
{% endif %} |
|
104 |
</div> |
|
105 | ||
99 | 106 |
</div> |
100 | 107 |
</div> |
108 |
</div> |
|
101 | 109 |
{% endblock %} |
chrono/manager/views.py | ||
---|---|---|
3674 | 3674 | |
3675 | 3675 |
class SharedCustodyAgendaMixin: |
3676 | 3676 |
agenda = None |
3677 |
tab_anchor = None |
|
3677 | 3678 | |
3678 | 3679 |
def set_agenda(self, **kwargs): |
3679 | 3680 |
self.agenda = get_object_or_404(SharedCustodyAgenda, id=kwargs.get('pk')) |
... | ... | |
3701 | 3702 |
return kwargs |
3702 | 3703 | |
3703 | 3704 |
def get_success_url(self): |
3704 |
return reverse('chrono-manager-shared-custody-agenda-settings', kwargs={'pk': self.agenda.id}) |
|
3705 |
url = reverse('chrono-manager-shared-custody-agenda-settings', kwargs={'pk': self.agenda.id}) |
|
3706 |
if self.tab_anchor: |
|
3707 |
url += '#open:%s' % self.tab_anchor |
|
3708 |
return url |
|
3705 | 3709 | |
3706 | 3710 | |
3707 | 3711 |
class SharedCustodyAgendaView(SharedCustodyAgendaMixin, RedirectView): |
... | ... | |
3808 | 3812 |
template_name = 'chrono/manager_agenda_form.html' |
3809 | 3813 |
form_class = SharedCustodyHolidayRuleForm |
3810 | 3814 |
model = SharedCustodyHolidayRule |
3815 |
tab_anchor = 'holidays' |
|
3811 | 3816 | |
3812 | 3817 | |
3813 | 3818 |
shared_custody_agenda_add_holiday_rule = SharedCustodyAgendaAddHolidayRuleView.as_view() |
... | ... | |
3819 | 3824 |
form_class = SharedCustodyHolidayRuleForm |
3820 | 3825 |
model = SharedCustodyHolidayRule |
3821 | 3826 |
pk_url_kwarg = 'rule_pk' |
3827 |
tab_anchor = 'holidays' |
|
3822 | 3828 | |
3823 | 3829 | |
3824 | 3830 |
shared_custody_agenda_edit_holiday_rule = SharedCustodyAgendaEditHolidayRuleView.as_view() |
... | ... | |
3828 | 3834 |
template_name = 'chrono/manager_confirm_delete.html' |
3829 | 3835 |
model = SharedCustodyHolidayRule |
3830 | 3836 |
pk_url_kwarg = 'rule_pk' |
3837 |
tab_anchor = 'holidays' |
|
3831 | 3838 | |
3832 | 3839 | |
3833 | 3840 |
shared_custody_agenda_delete_holiday_rule = SharedCustodyAgendaDeleteHolidayRuleView.as_view() |
... | ... | |
3838 | 3845 |
template_name = 'chrono/manager_agenda_form.html' |
3839 | 3846 |
form_class = SharedCustodyPeriodForm |
3840 | 3847 |
model = SharedCustodyPeriod |
3848 |
tab_anchor = 'time-periods' |
|
3841 | 3849 | |
3842 | 3850 | |
3843 | 3851 |
shared_custody_agenda_add_period = SharedCustodyAgendaAddPeriodView.as_view() |
... | ... | |
3849 | 3857 |
form_class = SharedCustodyPeriodForm |
3850 | 3858 |
model = SharedCustodyPeriod |
3851 | 3859 |
pk_url_kwarg = 'period_pk' |
3860 |
tab_anchor = 'time-periods' |
|
3852 | 3861 | |
3853 | 3862 | |
3854 | 3863 |
shared_custody_agenda_edit_period = SharedCustodyAgendaEditPeriodView.as_view() |
... | ... | |
3858 | 3867 |
template_name = 'chrono/manager_confirm_delete.html' |
3859 | 3868 |
model = SharedCustodyPeriod |
3860 | 3869 |
pk_url_kwarg = 'period_pk' |
3870 |
tab_anchor = 'time-periods' |
|
3861 | 3871 | |
3862 | 3872 | |
3863 | 3873 |
shared_custody_agenda_delete_period = SharedCustodyAgendaDeletePeriodView.as_view() |
tests/manager/test_shared_custody_agenda.py | ||
---|---|---|
40 | 40 |
resp.form['guardian'] = father.pk |
41 | 41 |
resp.form['days'] = list(range(7)) |
42 | 42 |
resp.form['weeks'] = 'even' |
43 |
resp = resp.form.submit().follow() |
|
43 |
resp = resp.form.submit() |
|
44 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/' % agenda.pk) |
|
45 |
resp = resp.follow() |
|
44 | 46 |
assert 'Custody rules are not complete.' in resp.text |
45 | 47 |
assert 'John Doe, daily, on even weeks' in resp.text |
46 | 48 | |
... | ... | |
55 | 57 | |
56 | 58 |
resp = resp.click('John Doe, daily, on even weeks') |
57 | 59 |
resp.form['days'] = list(range(6)) |
58 |
resp = resp.form.submit().follow() |
|
60 |
resp = resp.form.submit() |
|
61 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/' % agenda.pk) |
|
62 |
resp = resp.follow() |
|
59 | 63 |
assert 'Custody rules are not complete.' in resp.text |
60 | 64 | |
61 | 65 |
resp = resp.click('John Doe, from Monday to Saturday, on even weeks') |
... | ... | |
68 | 72 |
resp = resp.form.submit().follow() |
69 | 73 | |
70 | 74 |
resp = resp.click('remove', index=1) |
71 |
resp = resp.form.submit().follow() |
|
75 |
resp = resp.form.submit() |
|
76 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/' % agenda.pk) |
|
77 |
resp = resp.follow() |
|
72 | 78 |
assert SharedCustodyRule.objects.count() == 1 |
73 | 79 | |
74 | 80 | |
... | ... | |
86 | 92 |
resp.form['guardian'] = father.pk |
87 | 93 |
resp.form['date_start'] = '2022-03-01' |
88 | 94 |
resp.form['date_end'] = '2022-03-03' |
89 |
resp = resp.form.submit().follow() |
|
95 |
resp = resp.form.submit() |
|
96 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:time-periods' % agenda.pk) |
|
97 |
resp = resp.follow() |
|
90 | 98 |
assert 'This agenda doesn\'t have any custody period.' not in resp.text |
91 | 99 |
assert 'John Doe, 03/01/2022 → 03/03/2022' in resp.text |
92 | 100 | |
93 | 101 |
resp = resp.click('John Doe, 03/01/2022 → 03/03/2022') |
94 | 102 |
resp.form['guardian'] = mother.pk |
95 |
resp = resp.form.submit().follow() |
|
103 |
resp = resp.form.submit() |
|
104 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:time-periods' % agenda.pk) |
|
105 |
resp = resp.follow() |
|
96 | 106 |
assert 'Jane Doe, 03/01/2022 → 03/03/2022' in resp.text |
97 | 107 | |
98 | 108 |
resp = resp.click('Add custody period') |
... | ... | |
109 | 119 | |
110 | 120 |
resp = app.get('/manage/shared-custody/%s/settings/' % agenda.pk) |
111 | 121 |
resp = resp.click('remove', href='delete') |
112 |
resp = resp.form.submit().follow() |
|
122 |
resp = resp.form.submit() |
|
123 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:time-periods' % agenda.pk) |
|
124 |
resp = resp.follow() |
|
113 | 125 |
assert not SharedCustodyPeriod.objects.exists() |
114 | 126 | |
115 | 127 | |
... | ... | |
229 | 241 |
resp.form['holiday'].select(text='Vacances de Noël') |
230 | 242 |
resp.form['years'] = 'odd' |
231 | 243 |
resp.form['periodicity'] = 'first-half' |
232 |
resp = resp.form.submit().follow() |
|
244 |
resp = resp.form.submit() |
|
245 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:holidays' % agenda.pk) |
|
246 |
resp = resp.follow() |
|
233 | 247 |
assert SharedCustodyHolidayRule.objects.count() == 1 |
234 | 248 |
assert SharedCustodyPeriod.objects.count() == 3 |
235 | 249 |
assert 'This agenda doesn\'t have any custody period.' in resp.text |
236 | 250 | |
237 | 251 |
resp = resp.click('John Doe, Vacances de Noël, the first half, on odd years') |
238 | 252 |
resp.form['years'] = '' |
239 |
resp = resp.form.submit().follow() |
|
253 |
resp = resp.form.submit() |
|
254 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:holidays' % agenda.pk) |
|
255 |
resp = resp.follow() |
|
240 | 256 |
assert 'John Doe, Vacances de Noël, the first half' in resp.text |
241 | 257 |
assert SharedCustodyHolidayRule.objects.count() == 1 |
242 | 258 |
assert SharedCustodyPeriod.objects.count() == 6 |
... | ... | |
256 | 272 |
assert SharedCustodyPeriod.objects.count() == 12 |
257 | 273 | |
258 | 274 |
resp = resp.click('remove', index=1) |
259 |
resp = resp.form.submit().follow() |
|
275 |
resp = resp.form.submit() |
|
276 |
assert resp.location.endswith('/manage/shared-custody/%s/settings/#open:holidays' % agenda.pk) |
|
277 |
resp = resp.follow() |
|
260 | 278 |
assert SharedCustodyHolidayRule.objects.count() == 1 |
261 | 279 |
assert SharedCustodyPeriod.objects.count() == 6 |
262 | 280 | |
263 |
- |