38 lines
1.9 KiB
Python
38 lines
1.9 KiB
Python
from .models import Traveller, Family
|
|
|
|
|
|
def nightly_check_active_status():
|
|
for traveller in Traveller.objects.all():
|
|
start_date = traveller.travel_start_date
|
|
end_date = traveller.travel_end_date
|
|
is_active = traveller.is_active
|
|
traveller._update_active_status()
|
|
if start_date != traveller.travel_start_date or end_date != traveller.travel_end_date or is_active != traveller.is_active:
|
|
traveller.save()
|
|
|
|
for traveller in Traveller.objects.all():
|
|
if Family.objects.filter(traveller=traveller).exists():
|
|
continue
|
|
fam = Family()
|
|
fam.traveller = traveller
|
|
fam.residential_address = traveller.residential_address
|
|
fam.residential_suburb = traveller.residential_suburb
|
|
fam.postal_address = traveller.postal_address
|
|
fam.parent_A_firstname = traveller.parent_A_firstname
|
|
fam.parent_A_lastname = traveller.parent_A_lastname
|
|
fam.parent_A_phone = traveller.parent_A_phone
|
|
fam.parent_A_email = traveller.parent_A_email
|
|
fam.parent_B_firstname = traveller.parent_B_firstname
|
|
fam.parent_B_lastname = traveller.parent_B_lastname
|
|
fam.parent_B_phone = traveller.parent_B_phone
|
|
fam.parent_B_email = traveller.parent_B_email
|
|
fam.emergency_contact_A_firstname = traveller.emergency_contact_A_firstname
|
|
fam.emergency_contact_A_lastname = traveller.emergency_contact_A_lastname
|
|
fam.emergency_contact_A_phone = traveller.emergency_contact_A_phone
|
|
fam.emergency_contact_A_relation = traveller.emergency_contact_A_firstname
|
|
fam.emergency_contact_B_firstname = traveller.emergency_contact_B_firstname
|
|
fam.emergency_contact_B_lastname = traveller.emergency_contact_B_lastname
|
|
fam.emergency_contact_B_phone = traveller.emergency_contact_B_firstname
|
|
fam.emergency_contact_B_relation = traveller.emergency_contact_B_relation
|
|
fam.save()
|