Only allow sending of SMS to active students by default

This commit is contained in:
John Mullins
2023-10-11 15:03:42 +11:00
parent 3cfc4b545f
commit d68dcfccc1
2 changed files with 13 additions and 1 deletions
+12 -1
View File
@@ -65,9 +65,20 @@ class TravellerRollMixin:
def send_sms(self, request, queryset):
if 'send' in request.POST:
message = request.POST["message"]
send_to_parents = False
if request.POST.get("send_to_parents"):
send_to_parents = True
send_to_emergency_contacts = False
if request.POST.get("send_to_emergency_contacts"):
send_to_emergency_contacts = True
only_include_active_travellers = False
if request.POST.get("only_include_active_travellers"):
only_include_active_travellers = True
total = 0
for traveller in queryset:
total += traveller.send_sms(message, parents=True)
if only_include_active_travellers and not traveller.is_active():
continue
total += traveller.send_sms(message, parents=send_to_parents, emergency=send_to_emergency_contacts)
self.message_user(request, f"SMS has been sent to {total} recipients")
return HttpResponseRedirect(request.get_full_path())