本文整理匯總了Python中sellcard.common.Method.md5方法的典型用法代碼示例。如果您正苦於以下問題:Python Method.md5方法的具體用法?Python Method.md5怎麽用?Python Method.md5使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sellcard.common.Method
的用法示例。
在下文中一共展示了Method.md5方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: login
# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import md5 [as 別名]
def login(request):
user_name = mtu.getReqVal(request,"user_name","").strip()
password = mtu.getReqVal(request,"password","").strip()
vcode = mtu.getReqVal(request,"vcode","").strip()
try:
vcode2 = request.session["s_vcode"]
except:
vcode2 = ""
response_data = {}
try:
if vcode == vcode2:
# 查詢用戶信息
user = AdminUser.objects.get(user_name=user_name,is_enable='0')
upwd = user.password
password = mtu.md5(password)
shop_code=user.shop_code
rates = DiscountRate.objects.values('val_min','val_max','discount_rate').filter(shopcode=shop_code)
discLevelList = Shops.objects.values('disc_level').filter(shop_code=shop_code)
discLevel = ''
if len(discLevelList)>0:
discLevel = discLevelList[0]['disc_level']
rateList=[]
for rate in rates:
item={}
item['val_min']=float(rate['val_min'])
item['val_max']=float(rate['val_max'])
item['discount_rate']=float(rate['discount_rate'])
rateList.append(item)
if upwd == password:
request.session["s_uname"] = user.user_name
request.session["s_unameChinese"] = user.name
request.session["s_roleid"] = user.role_id
request.session["s_shopid"] = user.shop_id
request.session["s_shopcode"] = user.shop_code
request.session["s_depart"] = user.depart
request.session["s_uid"] = user.id
request.session["s_rates"] = rateList
request.session["disc_level"] = discLevel
#售卡前台
response_data['homeurl'] = cts.URL_HOME[0]
request.session["homeurl"] = response_data['homeurl']
# 查詢菜單權限
purlist = findNavByRcode(user.role_id)
request.session["s_umenu"] = getMenu(purlist)
response_data['status'] = "0"
else:
response_data['status'] = "2"
else:
response_data['status'] = "3"
except Exception as e:
print(e)
response_data['status'] = "1"
return HttpResponse(json.dumps(response_data), content_type="application/json")
示例2: updatePwd
# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import md5 [as 別名]
def updatePwd(request):
data = {}
if request.method == 'POST':
userId =request.session["s_uid"]
try:
newPwd = mtu.getReqVal(request,"newPwd","")
pwd = mtu.md5(newPwd)
AdminUser.objects.filter(id=userId).update(password=pwd)
data["result"] = "0"
except Exception as e:
print(e)
return render(request,'restPassword.html',locals())
示例3: save
# 需要導入模塊: from sellcard.common import Method [as 別名]
# 或者: from sellcard.common.Method import md5 [as 別名]
def save(request):
"""
提交用戶信息controllers
:param request:
:return:json
"""
res = {}
if request.method == 'POST':
# 檢測session中Token值,判斷用戶提交動作是否合法
Token = request.session.get('postToken', default=None)
# 獲取用戶表單提交的Token值
userToken = request.POST.get('postToken', '')
if userToken != Token:
res['status'] = 0
return HttpResponse(json.dumps(res))
user_id = request.POST.get('user_id')
user_name = request.POST.get('user_name')
name = request.POST.get('name')
shop_code = request.POST.get('shop_code')
depart = request.POST.get('depart')
role_id = request.POST.get('role')
is_enable = request.POST.get('is_enable')
if user_id == '':
flag = IsExist(user_name)
if flag > 0:
res['status'] = 0
res['msg'] = '該用戶名已存在'
return HttpResponse(json.dumps(res))
shop_id = None
if shop_code != '':
shop_id = Shops.objects.values('id').get(shop_code=shop_code)['id']
valid_date=None
if is_enable == '1':
valid_date = datetime.datetime.now()
try:
with transaction.atomic():
if user_id == '':
createNum = AdminUser.objects.create(user_name=user_name,
password=mth.md5('1'),
name=name,
shop_id=shop_id,
shop_code=shop_code,
depart=depart,
role_id=role_id,
is_enable=is_enable,
valid_date=valid_date)
if not createNum.id:
raise MyError('新建用戶失敗!')
else:
updataNum = AdminUser.objects.filter(id=int(user_id)) \
.update(name=name,
shop_id=shop_id,
shop_code=shop_code,
depart=depart,
role_id=role_id,
is_enable=is_enable,
valid_date=valid_date)
if updataNum != 1:
raise MyError('修改用戶失敗!')
except MyError as my_e:
res['status'] = 0
res['msg'] = my_e.value
return HttpResponse(json.dumps(res))
except Exception as e:
res['status'] = 0
res['msg'] = e
return HttpResponse(json.dumps(res))
res['status'] = 1
del request.session['postToken']
return HttpResponse(json.dumps(res))