本文整理匯總了Python中models.Customer.contain_email方法的典型用法代碼示例。如果您正苦於以下問題:Python Customer.contain_email方法的具體用法?Python Customer.contain_email怎麽用?Python Customer.contain_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Customer
的用法示例。
在下文中一共展示了Customer.contain_email方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: login
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import contain_email [as 別名]
def login(request):
info = ''
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if email == '[email protected]':
if password == 'password':
request.session['is_admin'] = True
request.session['uid'] = '-1'
request.session['user'] = 'HotelAdmin'
info = '登陸成功'
else :
info = '密碼錯誤!'
elif not Customer.contain_email(email):
info = 'EMAIL不存在!'
elif not Customer.is_auth(email, password):
info = '密碼錯誤!'
else:
customer = Customer.objects.get(email = email)
request.session['is_admin'] = False
request.session['uid'] = customer.customer_id
request.session['user'] = email
info = '登錄成功'
form = LoginForm()
return render(request, 'login.html', {'form' : form, 'info' : info})
示例2: login
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import contain_email [as 別名]
def login(request):
if request.method == "POST":
form = LoginForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
password = form.cleaned_data['password']
if not Customer.contain_email(email):
return render(request, 'login.html', {'form' : form , 'non_exist_email' : True})
elif not Customer.is_auth(email, password):
return render(request, 'login.html', {'form' : form , 'wrong_password' : True})
else:
print "login successfully"
form = LoginForm()
return render(request, 'login.html', {'form' : form})
示例3: login_api
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import contain_email [as 別名]
def login_api(request):
info = ''
status_code = -1
customer = None
if request.method == "GET":
form = request.GET
email = form['email']
password = form['password']
if not Customer.contain_email(email):
status_code = 1
elif not Customer.is_auth(email, password):
status_code = 2
else:
customer = Customer.objects.get(email = email)
status_code = 0
return render(request, 'auth.json', {'status_code' : status_code, 'customer' : customer})