本文整理汇总了Python中models.Request.email方法的典型用法代码示例。如果您正苦于以下问题:Python Request.email方法的具体用法?Python Request.email怎么用?Python Request.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Request
的用法示例。
在下文中一共展示了Request.email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile_edit
# 需要导入模块: from models import Request [as 别名]
# 或者: from models.Request import email [as 别名]
def profile_edit(request, l):
error_msg = None
me = l.get_ldap_node(request.session['ldap_binddn'])
if request.method == 'POST':
f = ProfileForm(request.POST)
if f.is_valid():
me.displayName = f.cleaned_data['name']
me.cn = f.cleaned_data['nick']
me.save()
passwd_new = f.cleaned_data['passwd']
email_new = f.cleaned_data['email']
if passwd_new:
me.set_password(passwd_new)
request.session['ldap_passwd'] = passwd_new
if email_new != str(me.mail):
req = Request()
req.type = Request.EMAIL
req.uid = me.uid
req.email = email_new
req.save()
t = loader.get_template('accounts/email_email_request')
c = Context({
'name': me.displayName,
'url': request.build_absolute_uri(
reverse(process, kwargs={ 'token': req.token })),
'expire_in': settings.REQ_EXPIRE_STR,
})
send_mail(u'Confirmation email FedeRez', t.render(c), settings.EMAIL_FROM,
[req.email], fail_silently=False)
return HttpResponseRedirect('/')
else:
f = ProfileForm(label_suffix='', initial={ 'email': me.mail,
'name': me.displayName,
'nick': me.cn })
c = { 'form': f,
'name': me.displayName,
'nick': me.cn,
'email': me.mail,
'error_msg': error_msg, }
c.update(csrf(request))
return render_to_response('accounts/edit.html', c,
context_instance=RequestContext(request))