Fixed family mapping in emergency export
This commit is contained in:
@@ -171,26 +171,27 @@ def emergency_contacts_context(queryset=None):
|
|||||||
traveller = travellerRoute.traveller
|
traveller = travellerRoute.traveller
|
||||||
if not traveller._is_active():
|
if not traveller._is_active():
|
||||||
continue
|
continue
|
||||||
parent_a = ""
|
for family in traveller.get_families():
|
||||||
if travellerRoute.traveller.parent_A_firstname:
|
parent_a = ""
|
||||||
parent_a = f"{traveller.parent_A_firstname} {traveller.parent_A_lastname} ({traveller.parent_A_phone})"
|
if family.parent_A_firstname:
|
||||||
parent_b = ""
|
parent_a = f"{family.parent_A_firstname} {family.parent_A_lastname} ({family.parent_A_phone})"
|
||||||
if travellerRoute.traveller.parent_B_firstname:
|
parent_b = ""
|
||||||
parent_b = f"{traveller.parent_B_firstname} {traveller.parent_B_lastname} ({traveller.parent_B_phone})"
|
if family.parent_B_firstname:
|
||||||
contact_a = ""
|
parent_b = f"{family.parent_B_firstname} {family.parent_B_lastname} ({family.parent_B_phone})"
|
||||||
if travellerRoute.traveller.emergency_contact_A_firstname:
|
contact_a = ""
|
||||||
contact_a = f"{traveller.emergency_contact_A_firstname} {traveller.emergency_contact_A_lastname} ({traveller.emergency_contact_A_phone})"
|
if family.emergency_contact_A_firstname:
|
||||||
contact_b = ""
|
contact_a = f"{family.emergency_contact_A_firstname} {family.emergency_contact_A_lastname} ({family.emergency_contact_A_phone})"
|
||||||
if travellerRoute.traveller.emergency_contact_B_firstname:
|
contact_b = ""
|
||||||
contact_b = f"{traveller.emergency_contact_B_firstname} {traveller.emergency_contact_B_lastname} ({traveller.emergency_contact_B_phone})"
|
if family.emergency_contact_B_firstname:
|
||||||
traveller_list.append({
|
contact_b = f"{family.emergency_contact_B_firstname} {family.emergency_contact_B_lastname} ({family.emergency_contact_B_phone})"
|
||||||
'traveller': traveller,
|
traveller_list.append({
|
||||||
'parent_a': parent_a,
|
'traveller': traveller,
|
||||||
'parent_b': parent_b,
|
'parent_a': parent_a,
|
||||||
'contact_a': contact_a,
|
'parent_b': parent_b,
|
||||||
'contact_b': contact_b,
|
'contact_a': contact_a,
|
||||||
'note': travellerRoute.notes
|
'contact_b': contact_b,
|
||||||
})
|
'note': travellerRoute.notes
|
||||||
|
})
|
||||||
bus_routes.append({'bus': bus, 'drivers': drivers, 'travellers': traveller_list})
|
bus_routes.append({'bus': bus, 'drivers': drivers, 'travellers': traveller_list})
|
||||||
|
|
||||||
return {'routes': bus_routes}
|
return {'routes': bus_routes}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class Traveller(models.Model):
|
|||||||
return f"${str(cost * stops)}"
|
return f"${str(cost * stops)}"
|
||||||
|
|
||||||
def _repopulate_address(self):
|
def _repopulate_address(self):
|
||||||
families = Family.objects.filter(traveller__id__exact=self.id)
|
families = self.get_families()
|
||||||
if families.count() == 0:
|
if families.count() == 0:
|
||||||
self.address = ""
|
self.address = ""
|
||||||
elif families.count() == 1:
|
elif families.count() == 1:
|
||||||
@@ -274,6 +274,9 @@ class Traveller(models.Model):
|
|||||||
def get_parsed_numbers(self, parents=False, emergency=False):
|
def get_parsed_numbers(self, parents=False, emergency=False):
|
||||||
return [] # Moved to family model. To remove from traveller model
|
return [] # Moved to family model. To remove from traveller model
|
||||||
|
|
||||||
|
def get_families(self):
|
||||||
|
return Family.objects.filter(traveller__id__exact=self.id)
|
||||||
|
|
||||||
|
|
||||||
class Family(models.Model):
|
class Family(models.Model):
|
||||||
RELATIONS = [
|
RELATIONS = [
|
||||||
|
|||||||
Reference in New Issue
Block a user