本文整理匯總了Python中models.Request.type方法的典型用法代碼示例。如果您正苦於以下問題:Python Request.type方法的具體用法?Python Request.type怎麽用?Python Request.type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Request
的用法示例。
在下文中一共展示了Request.type方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: profile_edit
# 需要導入模塊: from models import Request [as 別名]
# 或者: from models.Request import type [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))