本文整理汇总了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))