Show a child's guardians' phone numbers on their Personal information card

Member.guardians already scoped correctly to "the parents/guardians of
the families where this member is the CHILD" -- no model changes
needed. Adds clearly-labelled phone/emergency phone rows per guardian
plus a dial button each, following the same tel: link pattern already
used for the member's own numbers. Empty for members who aren't a
child in any family.
This commit is contained in:
2026-08-07 22:12:42 +02:00
parent 783b235bcd
commit 3d03ff644c
3 changed files with 64 additions and 0 deletions

View File

@@ -1087,6 +1087,37 @@ class MemberFamilyAttachDetachTests(ManagementTestBase):
self.assertNotIn(family, response.context["attach_to_family_form"].fields["family"].queryset)
def test_a_childs_page_shows_their_guardians_phone_numbers(self):
family = Family.objects.create()
parent = Member.objects.create(first_name="Pat", last_name="Parent", phone="+32470000001", emergency_phone="+32470000002")
FamilyMembership.objects.create(family=family, member=self.standalone, role=FamilyMembership.FamilyRole.CHILD)
FamilyMembership.objects.create(family=family, member=parent, role=FamilyMembership.FamilyRole.PARENT)
response = self.club_get("member_detail", self.standalone.pk)
self.assertIn(parent, response.context["guardians"])
self.assertContains(response, "Pat Parent")
self.assertContains(response, "tel:+32 470 00 00 01")
self.assertContains(response, "tel:+32 470 00 00 02")
def test_a_parents_page_does_not_show_guardian_numbers(self):
# self.standalone has no CHILD membership anywhere -- the section must not appear.
response = self.club_get("member_detail", self.standalone.pk)
self.assertEqual(len(response.context["guardians"]), 0)
self.assertNotContains(response, "Parent/guardian contact")
def test_a_guardian_with_no_phone_numbers_gets_no_dial_buttons(self):
family = Family.objects.create()
parent = Member.objects.create(first_name="Pat", last_name="Parent")
FamilyMembership.objects.create(family=family, member=self.standalone, role=FamilyMembership.FamilyRole.CHILD)
FamilyMembership.objects.create(family=family, member=parent, role=FamilyMembership.FamilyRole.PARENT)
response = self.club_get("member_detail", self.standalone.pk)
self.assertContains(response, "Pat Parent")
self.assertNotContains(response, "tel:")
class MemberDeleteTests(ManagementTestBase):
def setUp(self):