def update(request, uid): """执行编辑信息""" mod = Model('teacher') uid = str(uid) ob = mod.find("'" + uid + "'") if request.POST['old_password'] == '': context = {"info": "请输入登录密码"} return render(request, "web/info.html", context) else: import hashlib m = hashlib.md5() m.update(bytes(request.POST['old_password'], encoding='utf8')) if ob[0]['password'] == m.hexdigest(): if request.POST['password'] != '' and request.POST[ 'password'] == request.POST['repassword']: mod = Model('teacher') m = hashlib.md5() m.update(bytes(request.POST['password'], encoding='utf8')) kw = { 'no': uid, 'password': m.hexdigest(), } try: if mod.update(kw) > 0: context = {"info": "修改成功!"} else: context = {"info": "修改失败"} except Exception as err: print(err) context = {"info": "修改失败"} elif request.POST['password'] == '' and request.POST['phone'] != '': kw = { 'no': uid, 'phone': request.POST['phone'], } try: if mod.update(kw) > 0: context = {"info": "修改成功!"} else: context = {"info": "修改失败"} except Exception as err: print(err) context = {"info": "修改失败"} else: context = {"info": "无修改信息"} else: context = {"info": "修改失败"} return render(request, "web/info.html", context)
def update(request, uid): """执行编辑信息""" if request.POST['password'] == request.POST['repassword']: mod = Model('teacher') # 获取密码并md5 import hashlib m = hashlib.md5() m.update(bytes(request.POST['password'], encoding='utf8')) kw = { 'no': uid, 'faculty': request.POST['faculty'], 'age': request.POST['age'], 'sex': request.POST['sex'], 'position': request.POST['position'], 'degree': request.POST['degree'], 'phone': request.POST['phone'], 'password': m.hexdigest(), } try: if mod.update(kw) > 0: context = {"info": "修改成功!"} else: context = {"info": "修改失败"} except Exception as err: print(err) context = {"info": "修改失败"} else: context = {"info": "修改失败"} return render(request, "myadmin/info.html", context)
def update(request, uid): """执行编辑信息""" mod = Model('admin') ob = mod.find("'" + uid + "'") import hashlib m = hashlib.md5() m.update(bytes(request.POST['old_password'], encoding='utf8')) if request.POST['password'] == request.POST['repassword'] and ob[0][ 'password'] == m.hexdigest(): mod = Model('admin') m = hashlib.md5() m.update(bytes(request.POST['password'], encoding='utf8')) kw = { 'no': uid, 'password': m.hexdigest(), } try: if mod.update(kw) > 0: context = {"info": "修改成功!"} else: context = {"info": "修改失败"} except Exception as err: print(err) context = {"info": "修改失败"} else: context = {"info": "修改失败"} return render(request, "myadmin/info.html", context)
def update(request, uid): """执行编辑信息""" mod = Model('teaching') kw = { 'no': uid, 'subject': request.POST['subject'], 'class': request.POST['class'], } try: if mod.update(kw) > 0: context = {"info": "修改成功!"} else: context = {"info": "修改失败"} except Exception as err: print(err) context = {"info": "修改失败"} return render(request, "myadmin/info.html", context)