def get_and_send_best_note(klass): notes = klass.get_notes_near_current_location() if notes: note = notes[0] # send SMS re note resp = TwilioHelper.send_sms_for_note(note.get(Note.A_TEXT)) if resp: note[Note.A_DT_LAST_SENT] = datetime.datetime.now() Note.create_or_update_note(note)
def notify_users(klass, ride, match, action): ride = klass.format_ride(ride) match = klass.format_ride(match) # get name of the curr_user from_first_name = ride.get('user').get(User.A_FIRST_NAME) from_last_name = ride.get('user').get(User.A_LAST_NAME) # get the phone number of the match_id to_first_name = match.get('user').get(User.A_FIRST_NAME) to_phone_number = match.get('user').get(User.A_PHONE) if action == Ride.ACTION_REQUEST: note = "Hi %s, great news! %s wants to split a ride with you! Go to the app to check out details!" % (to_first_name, from_first_name +" "+ from_last_name) elif action == Ride.ACTION_ACCEPT: note = "Hi %s! %s has accepted your request to split a ride! Wahoo!" % (to_first_name, from_first_name) elif action == Ride.ACTION_DECLINE: note = "Sorry %s, %s has declined to split a ride." % (to_first_name, from_first_name) # send sms and return twilio response twilio_resp = TwilioHelper.send_sms(note, to_phone_number) if not twilio_resp: return ApiResponse.RIDE_COULD_NOT_REQUEST_MATCH