def _send_sms(research, remind_scientist):
    recipient_list = []
    for sr in list(research.scientistresearch_set.all()):
        basic_info = sr.scientist.userprofile.basic_info
        scientist_info = basic_info.get('scientist', {}) if basic_info else {}
        mobile = scientist_info.get('mobile', None)
        if mobile:
            recipient_list.append(filter(lambda x: x.strip() != "", mobile))

    notification = {
        'subject': remind_scientist.message,
        'recipient_list': recipient_list,
        'html_content': remind_scientist.message,
        'account_sid': settings.TWILIO_ACCOUNT_SID,
        'auth_token': settings.TWILIO_AUTH_TOKEN,
        'from_number': settings.TWILIO_FROM_NUMBER,
    }

    send_sms.delay(notification)
def _send_sms(research, remind_participant, event):
    recipient_list = []

    for pr in list(research.participantresearch_set.filter(confirmed=True)):
        participant_event = ParticipantResearchEvent.objects.filter(research_event=event,
                                                                    participant=pr.participant)
        if participant_event:
            basic_info = participant_event[0].participant.userprofile.basic_info
            participant_info = basic_info.get('participant', {}) if basic_info else {}
            mobile = participant_info.get('mobile', None)
            if mobile:
                recipient_list.append(filter(lambda x: x.strip() != "", mobile))

    notification = {
        'subject': remind_participant.message,
        'recipient_list': recipient_list,
        'html_content': remind_participant.message,
        'account_sid': settings.TWILIO_ACCOUNT_SID,
        'auth_token': settings.TWILIO_AUTH_TOKEN,
        'from_number': settings.TWILIO_FROM_NUMBER,
    }

    send_sms.delay(notification)