コード例 #1
0
ファイル: views.py プロジェクト: manibhushan05/tms
def send_otp(phone, email):
    phone_otp = PhoneOTP.generate(phone=phone)
    sms_text = "%s is your code to reset your Aaho password. Don't reply to this message with your code." % phone_otp
    send_sms(phone, sms_text)
    email_otp = EmailOTP.generate(email=email)
    email_text = "This is your one-time password: %s " % email_otp
    email = EmailMessage(subject='Password reset request', body=email_text, reply_to=['*****@*****.**'], to=[email])
    if settings.ENABLE_MAIL and not settings.TESTING:
        email.send()
コード例 #2
0
ファイル: tasks.py プロジェクト: manibhushan05/tms
def notify_inactive_driver_apps():
    engaged_vehicle_ids = set(
        VehicleAllocated.objects.values_list('vehicle_number_id', flat=True))
    driver_ids = set(
        Vehicle.objects.filter(id__in=engaged_vehicle_ids,
                               driver_app_user__isnull=False).values_list(
                                   'driver_app_user_id', flat=True))
    recent_gps_data = GPSLogNew.objects.filter(
        driver__in=driver_ids).latest('datetime')
    notify_time = timezone.now() - timedelta(hours=SMS_NOTIFY_TIME_GAP)
    inactive_drivers_data = dict([(g.driver_id, g.datetime)
                                  for g in recent_gps_data
                                  if g.datetime <= notify_time])

    vehicles = Vehicle.objects.filter(driver_id__in=inactive_drivers_data.keys(
    )).select_related('driver_app_user')

    to_notify_vehicles = []
    notify_after = timezone.now() - timedelta(hours=SMS_NOTIFY_TIME_GAP)
    for v in vehicles:
        notif_time = v.driver_app_user.inactive_sms_sent_at
        if not notif_time:
            to_notify_vehicles.append(v)
        if notif_time < notify_after:
            to_notify_vehicles.append(v)

    if not to_notify_vehicles:
        return

    sms_data = [{
        'driver_id':
        v.driver_app_user_id,
        'phone':
        v.driver_app_user.driver_number,
        'name':
        v.driver_app_user.driver_name,
        'vehicle_number':
        v.vehicle_number,
        'last_update_gap':
        (timezone.now() -
         inactive_drivers_data[v.driver_app_user_id]).total_seconds() / 3600,
    } for v in to_notify_vehicles]

    sms_text = [(sms_data['driver_id'], sms_data['phone'],
                 SMS_TEMPLATE.format(data)) for data in sms_data]
    for driver_id, phone, text in sms_text:
        send_sms(phone, text)
        DriverAppUser.objects.filter(driver_id=driver_id).update(
            inactive_sms_sent_at=timezone.now())
        print('[notify_inactive_driver_apps] SMS sent to ' + phone + ': ' +
              sms_text)
コード例 #3
0
def send_app_update_sms_to_fms_users(request):
    if not request.data.get('app_link'):
        return json_response({'status': 'failure', 'msg': 'Pls pass app link'})
    brokers = Broker.objects.all().exclude(deleted=True)
    mobiles_list = []
    for broker in brokers:
        if broker:
            usr = broker.name
            if any(g.name == 'fms' for g in usr.groups.all()):
                if broker.get_phone() not in mobiles_list:
                    mobiles_list.append(broker.get_phone())
    mobiles = ', '.join(mobiles_list)
    print(mobiles)
    template = "We have added new features to Aaho FMS app. Please click the link to update: {}".format(
        request.data.get('app_link'))
    print(template)
    send_sms(mobiles, template)
    return json_response({
        'status': 'success',
        'msg': 'Sms sent successfully  to FMS users'
    })
コード例 #4
0
def send_app_sms():
    df=pd.read_excel('/Users/mani/Downloads/fms_users.xlsx')
    for i,row in df.iterrows():
        sms_template=u"नववर्ष में Aaho FMS ऍप डाउनलोड करें - http://bit.ly/2zZuTwL \n इस ऍप में अपनी हर ट्रिप की एडवांस, बैलेन्स और अन्य सारी जानकारी देखें, अगले दिन की लोडिंग सुनिश्चित करें, और गाड़ियों की GPS ट्रैकिंग देखें। यह सुविधा Aaho के विशिष्ट साझीदारों के लिए बिल्कुल मुफ्त है. धन्यवाद.\n आपका Username: {}  और Password: {}  है.".format(row['username'],row['password'])
        print(sms_template,row['phone'])
        send_sms(message=sms_template,mobiles=row['phone'])
コード例 #5
0
def send_sms_to_suppliers(mobiles, template):
    if settings.ENABLE_SMS:
        send_sms(mobiles, template)
    else:
        msg = "SMS sent to: {} Body: {}".format(mobiles, template)
        print(msg)
コード例 #6
0
def send_otp_sms(mobiles, text):
    send_sms(mobiles, text)
コード例 #7
0
ファイル: views.py プロジェクト: manibhushan05/tms
def send_otp_sms(phone):
    otp = OTP.generate(phone)
    text = '%s is your OTP for Aaho Driver App phone number verification' % otp
    send_sms(phone, text)