def organizations_dashboard(): form = SendTextForm() form.location.choices = Location.get_choices() if request.method == 'POST': form.process(request.form) if form.validate(): send_text_messages(get_sms_data_from_form(form)) flash('Your message was successfully sent!') return render_template('organizations/dashboard.html', form = form)
def recipients_sign_up(): form = SignUpRecipientForm() form.location.choices = Location.get_choices() if request.method == 'POST': form.process(request.form) if form.validate(): recipient = Recipient.new( form.phone_number.data, form.location.data ) recipient.save() return render_template('recipients/sign-up.html', form = form)
def get_sms_data_from_form(form): location = Location.get( Location.id == form.location.data ) phone_numbers = [ recipient.phone_number for recipient in location.recipient_set ] return { 'location': location.get_short_name(), 'phone_numbers': phone_numbers, 'water': form.water.data, 'medicine': form.medicine.data, 'food': form.food.data, 'clothing': form.clothing.data, 'eta': form.eta.data }