本文整理汇总了Python中bedrock.firefox.forms.SMSSendForm.errors['__all__']方法的典型用法代码示例。如果您正苦于以下问题:Python SMSSendForm.errors['__all__']方法的具体用法?Python SMSSendForm.errors['__all__']怎么用?Python SMSSendForm.errors['__all__']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bedrock.firefox.forms.SMSSendForm
的用法示例。
在下文中一共展示了SMSSendForm.errors['__all__']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sms_send
# 需要导入模块: from bedrock.firefox.forms import SMSSendForm [as 别名]
# 或者: from bedrock.firefox.forms.SMSSendForm import errors['__all__'] [as 别名]
def sms_send(request):
form = SMSSendForm(request.POST or None)
if request.method == 'POST' and form.is_valid():
try:
basket.send_sms(form.cleaned_data['number'],
'SMS_Android',
form.cleaned_data['optin'])
except basket.BasketException:
msg = form.error_class(
[_('An error occurred in our system. '
'Please try again later.')]
)
form.errors['__all__'] = msg
else:
return HttpResponseRedirect(
reverse('firefox.android.sms-thankyou'))
return l10n_utils.render(request, 'firefox/android/sms-send.html',
{'sms_form': form})
示例2: sms_send
# 需要导入模块: from bedrock.firefox.forms import SMSSendForm [as 别名]
# 或者: from bedrock.firefox.forms.SMSSendForm import errors['__all__'] [as 别名]
def sms_send(request):
form = SMSSendForm(request.POST or None)
if request.method == 'POST':
error_msg = _('An error occurred in our system. Please try again later.')
error = None
if form.is_valid():
try:
basket.send_sms(form.cleaned_data['number'],
'SMS_Android',
form.cleaned_data['optin'])
except basket.BasketException:
error = error_msg
else:
number_errors = form.errors.get('number')
if number_errors:
# form error messages may contain unsanitized user input
error = escape(number_errors[0])
else:
error = error_msg
if request.is_ajax():
# return JSON
if error:
resp = {
'success': False,
'error': error,
}
else:
resp = {'success': True}
return HttpResponseJSON(resp)
else:
if error:
form.errors['__all__'] = form.error_class([error])
else:
return HttpResponseRedirect(reverse('firefox.android.sms-thankyou'))
return l10n_utils.render(request, 'firefox/android/sms-send.html',
{'sms_form': form})