forms: send mobile phone verification code synchronously

This commit is contained in:
Benjamin Dauvergne 2013-09-14 02:00:40 +02:00
parent a9e6f99de5
commit aeba55812b
2 changed files with 21 additions and 11 deletions

View File

@ -447,10 +447,15 @@ class ProfileForm(ModelForm):
try:
sms_carrier = notification.SMSNotifier.get_carrier()
sms_carrier.send_sms((mobile_phone,), 'code is ' + code)
return True
except Exception:
logger.exception('failure in SMS background thread')
thread = threading.Thread(target=send_sms, args=(mobile_phone, code))
thread.start()
logger.exception('unable to send SMS verification code %r to %r',
code, mobile_phone)
self.request.record('error', 'unable to send SMS verification code {code} to {mobile_phone}',
mobile_phone=mobile_phone, code=code)
return False
if not send_sms(mobile_phone, code):
raise ValidationError(_('Unable to send you the SMS code, try again.'))
self.fields['code'] = CharField(label='Code')
i = self.layout.fields.index('mobile_phone')
self.layout.fields.insert(i+1, 'code')

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: docbow 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-09-12 18:30+0200\n"
"PO-Revision-Date: 2013-09-12 18:30+0200\n"
"POT-Creation-Date: 2013-09-13 19:00+0200\n"
"PO-Revision-Date: 2013-09-13 19:01+0200\n"
"Last-Translator: Benjamin Dauvergne <bdauvergne@entrouvert.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -301,15 +301,20 @@ msgstr ""
"code vous sera envoyé et il vous faudra valider une deuxième fois votre "
"numéro avec le code."
#: forms.py:457
#: forms.py:458
msgid "Unable to send you the SMS code, try again."
msgstr "L'envoi du code de vérification de votre numéro mobile a échoué; "
"veuillez ré-essayer plus tard."
#: forms.py:462
msgid "Enter code received by SMS"
msgstr "Entrez le code reçu par SMS"
#: forms.py:478
#: forms.py:483
msgid "E-mail or identifier"
msgstr "E-mail ou nom d'utilisateur"
#: forms.py:494
#: forms.py:499
msgid ""
"That e-mail address or identifier doesn't have an associated user account. "
"Are you sure you've registered?"
@ -317,15 +322,15 @@ msgstr ""
"Cette adresse email ou cet identifiant n'ont pas de compte utilisateur "
"associé.Êtes-vous bien sûr d'être enregistré?"
#: forms.py:512
#: forms.py:517
msgid "From"
msgstr "De"
#: forms.py:513 templates/docbow/message.html:34
#: forms.py:518 templates/docbow/message.html:34
msgid "To"
msgstr "Destinataire(s)"
#: forms.py:528
#: forms.py:533
msgid "From must be inferior or equal to To"
msgstr "Le début de la période doit être inférieur ou égal à sa fin"