當前位置: 首頁>>代碼示例>>Python>>正文


Python Request.email方法代碼示例

本文整理匯總了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))
開發者ID:gpichot,項目名稱:webldap,代碼行數:53,代碼來源:views.py


注:本文中的models.Request.email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。