示例#1
0
 def notify(cls, request, message=None, force=False):
     obj = cls.objects.filter(user=request.user)
     if (obj.exists() and obj[0].enabled) or force:
         obj = UserAuthPhone.objects.filter(user=request.user)
         message = message if message else SMS_NOTIFICATION_MESSAGE
         if obj.exists():
             send_sms(SMS_FROM, Sign().unsign(obj[0].phone), message)
         elif request.user.email:
             send_mail(
                 [request.user.email], MAIL_DEFAULT_SUBJECT, message)
示例#2
0
 def notify(cls, request, message=None, force=False):
     obj = cls.objects.filter(user=request.user)
     if (obj.exists() and obj[0].enabled) or force:
         obj = UserAuthPhone.objects.filter(user=request.user)
         message = message if message else SMS_NOTIFICATION_MESSAGE
         if obj.exists():
             send_sms(SMS_FROM, Sign().unsign(obj[0].phone), message)
         elif request.user.email:
             send_mail(
                 [request.user.email], MAIL_DEFAULT_SUBJECT, message)
示例#3
0
 def send_sms(self):
     code = str(RandomPassword().get(SMS_CODE_LEN, SMS_ASCII)).lower()
     send_sms(SMS_FROM, Sign().unsign(self.phone), SMS_MESSAGE % code)
     self.code = Sign().sign(code)
     self.save()
示例#4
0
 def send_sms(self):
     code = str(RandomPassword().get(SMS_CODE_LEN, SMS_ASCII)).lower()
     send_sms(SMS_FROM, Sign().unsign(self.phone), SMS_MESSAGE % code)
     self.code = Sign().sign(code)
     self.save()