def add_admin(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "POST": user_name = req.POST.get("account", None) name = req.POST.get("name", None) password = req.POST.get("password", None) #againpassword = req.POST.get("againpassword", None) #if againpassword != password: # return HttpResponse('两次密码不一样') result = mSet_admin.add_admin(user_name, name, password) if result == 0: return handler500(req) elif result == 1: return HttpResponse('账号已经存在,请设置其他账号') elif result == 666: return HttpResponse("1") #添加账号成功 else: result = mSet_admin.search_admin_account() if result == 0: return handler500(req) else: context = {'admin_infos_list': result} return render(req, 'admin/add_admin.html', context)
def manage_deal(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "POST": seller_merchant_id = req.POST.get('seller_merchant_id', 0) buyer_merchant_id = req.POST.get('buyer_merchant_id', 0) car_id = req.POST.get('car_id', 0) deal_price = req.POST.get('deal_price', 0.0) seller_merchant_id = 1 buyer_merchant_id = 1 car_id = 1 result = mDeal.insert_deal_table(seller_merchant_id, buyer_merchant_id, car_id, deal_price) if result == 0: return handler500(req) else: return HttpResponse(result) #context = {'user_list': result} #return render(req, 'admin/manage_deal.html', context) else: result = mDeal.get_all_user_info_list() if result == 0: return handler500(req) else: context = {'user_list': result} return render(req, 'admin/manage_deal.html', context)
def set_account(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') username = mSet_account.getUsername(admin_id) if username == 0: return handler500(req) if req.method == "POST": old_password = req.POST.get("old_password", None) new_password = req.POST.get("new_password", None) name = req.POST.get("name", None) result = mSet_account.setAccount2(username, name, old_password, new_password) if result == 0: return handler500(req) elif result == 1: return HttpResponse('用户不存在') elif result == 666: return HttpResponse("1") else: context = {"notice": notice, "account_name": username} return render(req, 'admin/setting/account_setting.html', context) context = {'account': username} return render(req, 'admin/set_account.html', context)
def search_from_my_demand(req): #从‘我的需求’那里传递过来的(也就是说从记录我的需求的记录表里面获取的) mTools = Tools() user_id = mTools.getSession(req,'user_id')#调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'GET': operation_id = req.GET.get('operation_id',0) result = mKeyword_search.getDataFromMyDemands(operation_id, user_id) #根据用户的需求的记录id和其电话号码来查询 if result == 0: return handler500(req) else: condition = result cars_infos = mKeyword_search.OneWordGetData(condition) if cars_infos == 0: return handler500(req) else: deleteAllSession(req) length_cars_infos = len(cars_infos) req.session['search_datas'] = cars_infos req.session['length_search_datas'] = length_cars_infos return HttpResponseRedirect("/search/") else: return handler404(req)
def edit_vip_in_all_vip(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': trademark = req.POST.get('trademark', 0) operation_id = req.POST.get('operation_id', 0) operation_id = 1 #假设为1先 condition = {} condition['trademark'] = trademark result = mVIP.edit_vip(operation_id, condition) if result == 0: return handler500(req) elif result == 666: return HttpResponseRedirect('/allVipHome/') else: operation_id = req.GET.get('operation_id', 0) result = mVIP.preview_vip(operation_id) if result == 0: return handler500(req) else: context = {'vip_info': result} return render(req, 'admin/edit_vip.html', context)
def admin_login(req): if req.method == 'POST': #获取表单用户名和其密码 username = req.POST.get('user_name', None) password = req.POST.get('password', None) mTools = Admin_tools() user_ip = mTools.get_client_ip(req) #获取用户的IP admin_id = mLogin.login( user_ip, username, password ) #返回0表示验证失败,返回1表示手机号或者密码有错;返回登录活动记录表的id表示登录成功,返回404表示登录被限制 if admin_id == 0: return handler500(req) elif admin_id == -1: #返回1表示手机号或者密码有错 return HttpResponse('0') elif admin_id == -404: #登录时,错误次数超过6次,锁住IP,返回404 return HttpResponse('2') else: #验证成功 id = mLogin.activity_log(admin_id, user_ip) if id == 0: return handler500(req) req.session['admin_id'] = admin_id #建立一个会话,该管理员的id req.session['admin_login_id'] = id #用来在退出时,找到相应的登录记录,从而修改登录退出的时间 #return HttpResponseRedirect('/adminHome/') #转向登录成功后的页面 return HttpResponse('1') else: #GET请求 return render(req, 'admin/home/login.html')
def verify_register(req): if req.method == 'POST': #点击注册按钮,需要全面检查 mTools = Tools() user_name = req.POST.get('userName', '') phone = req.POST.get('registerPhoneNumber', '') password = req.POST.get('password', '') myverifyCode = req.POST.get('verifyCode', None) #获取表单的验证码 #验证码验证 verifyCode = mTools.getSession(req, 'verifyCode') #获取会话的验证码 if myverifyCode != verifyCode: #验证码不对 return HttpResponse('0') else: mTools.delSession(req, 'verifyCode') phones = mTools.getSession(req, "phones") flag = False for i in range(len(phones)): #判断输入的电话号码是否是受到了邀请 if phones[i] == phone: flag = True break if flag == False: #电话号码不存在,返回1.没有受到邀请(尽管邀请码正确,但是可能是看到别人的或者猜中的) return HttpResponse('0') user_ip = mTools.get_client_ip(req) #获取用户的IP user_id = mRegister.register( user_name, phone, password, user_ip) #调用该函数处理这个url.数据库出错,返回0;用户已经存在,返回1;成功则返回用户的id if user_id == 0: return handler500(req) elif user_id == -1: #用户已经存在 return HttpResponse('0') else: mTools.delSession(req, 'phones') #数据传递完毕,删除该会话 mTools.delSession(req, 'verifyCode') #验证完毕,删除该验证码会话 login_id = mRegister.finishRegister( user_ip, user_id) #调用这个函数来记录用户注册成功后的活动记录,与记录登录活动记录一样 if login_id == 0: return handler500(req) else: req.session['user_id'] = user_id #建立一个会话 req.session[ 'login_id'] = login_id #用来在退出时,找到相应的登录记录,从而修改登录退出的时间 return HttpResponse('1') else: return handler404(req) #404 请求错误
def invalid_time_publish(req, merchant_id): car = mPersonal_center.findInvalidTimeCar(merchant_id) #调用这个函数来查询过期里的车源信息 if car == 0: return handler500(req) #查看过期车源失败 all_cars_infos = mPersonal_center.findPersonalCenterCar( car) #存储所有与该商家号码相关的车的信息 return all_cars_infos
def keyword_search(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "POST": condition = {} condition['user_company_name'] = req.POST.get('user_company_name', None) condition['user_type'] = req.POST.get('user_type', None) condition['user_trademark'] = req.POST.get('user_trademark', None) condition['province'] = req.POST.get('province', None) condition['city'] = req.POST.get('city', None) condition['user_name'] = req.POST.get('user_name', None) condition['user_phone'] = req.POST.get('user_phone', None) result_list = mAdmin_search.OneWordGetData(condition) if result_list == 0: return handler500(req) else: req.session['search_datas'] = result_list req.session['length_search_datas'] = len(result_list) return HttpResponseRedirect("/viewSearch/") else: return handler404(req)
def login(req): if req.method == "POST": #获取表单用户名和其密码 user_name = req.POST.get('userName', '') password = req.POST.get('password', '') mTools = Tools() user_ip = mTools.get_client_ip(req) #获取用户的IP result = mLogin.login( user_ip, user_name, password ) #返回0表示验证失败,返回1表示手机号或者密码有错;返回登录活动记录表的id表示登录成功,返回404表示登录被限制 if result == 0: return handler500(req) elif result == 1: #返回1表示手机号或者密码有错 return HttpResponse('0') elif result == 404: return render(req, 'limit.html', status=404) else: #验证成功 try: wei_xin_users = weiXinUser.objects.filter( openid=global_from_user) if not wei_xin_users: #没有通过用户OpenID和系统用户进行绑定 wei_xin_user = weiXinUser.objects.create( openid=global_from_user, phone=user_name) #绑定微信用户和系统用户 except: return HttpResponse('0') return HttpResponse('1') else: return render(req, 'weixin/login.html')
def my_demand(req): mTools = Tools() user_id = mTools.getSession(req,'user_id')#调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') brand_list = ["路虎", "法拉利", "劳斯莱斯"] car_series_list = ["SUV", "中规车", "越野车"] if req.method == 'GET': record_list = mMy_demands.searchMyDemands(user_id) #调用这个函数来查询我的需求 if record_list == 0: return handler500(req) #查询我的需求失败 context = {"is_login": True, "demand_list": record_list, "brand_list": brand_list, "car_series_list": car_series_list} return render(req, "myDemand.html", context) else: actionType = req.POST.get('actionType',None) demandId = req.POST.get('demandId',None) if actionType is not None: if actionType == '0': if demandId is not None: return delete_demand(req, demandId) #删除我的需求 else: return HttpResponse('0') elif actionType == '1': return update_record(req, user_id) #修改我的需求 else: return handler404(req) #404 请求错误
def modify_admin(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "POST": user_name = req.POST.get("account", None) name = req.POST.get("name", None) old_password = req.POST.get("oldpassword", None) new_password = req.POST.get("newpassword", None) againpassword = req.POST.get("againpassword", None) if againpassword != new_password: return HttpResponse('两次新密码不一样') result = mSet_admin.modify_adamin(user_name, name, old_password, new_password) if result == 0: return handler500(req) elif result == 1: return HttpResponse('用户不存在') elif result == 666: return HttpResponse('修改成功') else: return render(req, 'admin/modify_admin.html')
def publish(req): mTools = Tools() user_id = mTools.getSession( req, 'user_id') #调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': #提交 publish_info = getFormData(req) #获取表单数据 req.session['publish_info'] = publish_info #建立一个会话,传递数据 context = {"is_login": True, 'source_detail_list': publish_info} return render(req, "publish.html", context) else: #先检查该用户是否具备发布车的权限a #try: # user=audit_table.objects.get(phone=current_user_phone_number) # if user.license != 1 or user.IDcard != 1: # return HttpResponseRedirect('/publish_car/no_permisson/') #except: # return HttpResponseRedirect('/publish_car/no_permisson/') #从导航栏“发布车源”进入的 contact = mPublish_car.getPublishPeople(user_id) if contact == 0: return handler500(req) else: context = {"is_login": True, "contact": contact} #传递联系人 return render(req, "publish.html", context)
def change_password(request): mTools = Tools() current_user_phone_number = mTools.getSession(request,'current_user_phone_number')#调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if current_user_phone_number is None: return HttpResponseRedirect('/sessionExceedTime/') if request.method == 'POST': if 'saveButton' in request.POST: oldPassword = request.POST.get('oldPassword', '') newPassword = request.POST.get('newPassword', '') againPassword = request.POST.get('againPassword', '') # email = request.POST.get('email', '') #邮箱 # result_code = mChange_password.changePassword(current_user_phone_number,oldPassword,newPassword,email) #调用这个函数处理用户旧密码验证以及旧密码修改 if result_code == 0: return handler500(request) #数据库更新出错 elif result_code == 1: context = {"is_login": True,'oldpassword_is_wrong':True,'phone':current_user_phone_number} return render(request, "setting.html", context) elif result_code == 666: context = {"is_login": True,'phone':current_user_phone_number,'changepwd_success':True,'picture':'images/temp/5.jpg'} return render(request, "setting.html", context) else: context = {"is_login": True,'phone':current_user_phone_number} return render(request, "setting.html", context)
def personal_center(req): mTools = Tools() user_id = mTools.getSession( req, 'user_id') #调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'GET': merchant_material = mPersonal_center.getMyInfo(user_id) if merchant_material == 0: return handler500(req) #查询失败 elif merchant_material == 404: context = {"is_login": True} return render(req, 'to_completeMaterial.html', context) #return HttpResponseRedirect('/completeMaterial/') else: merchant_id = merchant_material.get('id') publish_info = valid_time_publish(req, merchant_id) exceed_publish = invalid_time_publish(req, merchant_id) context = { "is_login": True, 'merchant_material': merchant_material, 'publish_info': publish_info, 'exceed_publish': exceed_publish } return render(req, 'homePage.html', context) else: return handler404(req)
def change_phone(request): mTools = Tools() current_user_phone_number = mTools.getSession(request,'current_user_phone_number')#调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if current_user_phone_number is None: return HttpResponseRedirect('/sessionExceedTime/') if request.method == 'POST': oldPhone = request.POST.get('oldPhoneNumber', '') newPhone = request.POST.get('newPhoneNumber', '') password = request.POST.get('password', '') myverifyCode = request.POST.get('verifyCode','') #获取表单的验证码 #验证码验证 verifyCode = mTools.getSession(request,'changePhoneVerifyCode') #获取会话的验证码 if myverifyCode != verifyCode: #验证码不对 return HttpResponse('0') result_code = mChange_phone.changePhone(oldPhone,password,newPhone) #调用这个函数处理用户旧密码验证以及旧密码修改 if result_code == 0: return handler500(request) #数据库更新出错 elif result_code == 1: context = {"is_login": True,'oldpassword_is_wrong':True,'phone':current_user_phone_number} return render(request, "setting.html", context) elif result_code == 666: context = {"is_login": True,'phone':current_user_phone_number,'success':True,'picture':'images/temp/5.jpg'} return render(request, "setting.html", context) else: context = {"is_login": True,'phone':current_user_phone_number} return render(request, "setting.html", context)
def admin_invite_friend(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': #获得当前时间时间戳 now_time = int(time.time()) #这是时间戳,即将当前时间转换为的毫秒数 last_time = mTools.getSession(req, 'last_time') if last_time is not None: if (now_time - last_time) < (1 * 60 * 1000): #1分钟 req.session['last_time'] = now_time return HttpResponse('2') #操作过于频繁 else: req.session['last_time'] = now_time else: req.session['last_time'] = now_time mobiles = req.POST.getlist("phoneNumberList[]") current_user_phone_number = 'admin' result = mInvite_friends.inviteFriend(current_user_phone_number, mobiles) #调用这个函数处理当前用户输入的电话号码 if result == 0: return handler500(req) #更新或者插入邀请码出错 else: success = result['success'] fail = result['fail'] return HttpResponse('1') else: #get请求 context = {"is_login": True} return render(req, "sendInvitationCode.html", context)
def login(req): if req.method == "POST": #获取表单用户名和其密码 user_name = req.POST.get('userName', '') password = req.POST.get('password', '') mTools = Tools() user_ip = mTools.get_client_ip(req) #获取用户的IP result = mLogin.login(user_ip, user_name, password) if result == 0: return handler500(req) elif result == 1: #返回1表示手机号或者密码有错 return HttpResponse('0') elif result == 404: #登录时,错误次数超过6次,锁住IP,返回404 return HttpResponse('2') else: #验证成功 try: wei_xin_users = weiXinUser.objects.filter(phone=result) if not wei_xin_users: #没有通过用户OpenID和系统用户进行绑定 #绑定微信用户和系统用户 user = weiXinUser.objects.create(phone=result) return HttpResponse(user.id) return HttpResponse('#') except: return HttpResponse('0') else: return render(req, 'weixin/login.html')
def verify_invitation_code(req): if req.method == 'POST': #获得表单数据 invitationCode = req.POST.get('invitationCode', '') mTools = Tools() user_ip = mTools.get_client_ip(req) #获取用户的IP phones = mInvite_code.mangageInviteCode( invitationCode, user_ip) #返回1表示邀请码过期,返回2表示邀请码不存在或者有错,返回3表示邀请码不能为空,返回404表示登录被限制 if phones == 0: return handler500(req) elif phones == 1: #邀请码过期 return HttpResponse('0') elif phones == 2: #邀请码不存在或者有错 return HttpResponse('0') elif phones == 3: #邀请码不能为空 return HttpResponse('0') elif phones == 404: #return render(req, 'limit.html', status=404) return HttpResponse('错误次数过多,稍后重试') else: #邀请码验证成功 req.session["phones"] = phones #建立一个会话,传递找到的符合条件的电话号码 return HttpResponse('1') else: return handler404(req) #404 请求错误
def verify_login(req): if req.method == 'POST': #获取表单用户名和其密码 user_name = req.POST.get('userName', '') password = req.POST.get('password', '') avoid_login = req.POST.get('avoidLogin', '0') # 免登陆 mTools = Tools() user_ip = mTools.get_client_ip(req) #获取用户的IP user_id = mLogin.login( user_ip, user_name, password ) #返回0表示验证失败,返回1表示手机号或者密码有错;返回登录活动记录表的id表示登录成功,返回404表示登录被限制 if user_id == LoginStatus.SERVER_ERROR: #服务器出错 return handler500(req) elif user_id == LoginStatus.WRONG: #返回1表示手机号或者密码有错 return HttpResponse('0') elif user_id == LoginStatus.ERROR_EXCEED: #登录时,错误次数超过6次,锁住IP,返回404 return HttpResponse('2') elif user_id == LoginStatus.IS_BLACK: #该账号已经被拉黑 return HttpResponse('3') else: #验证成功 #user_have_login = mTools.getSession(req,'phone') #if user_have_login == result: # return HttpResponse('该用户已经登录,如果要重新登录,请先前往去退出该账号。') id = mLogin.activity_log(user_id, user_ip) if id == 0: return handler500(req) if avoid_login == '1': req.session.set_expiry(7 * 24 * 60 * 60) #一周免登陆 req.session['user_id'] = user_id #建立一个会话 req.session['login_id'] = id #用来在退出时,找到相应的登录记录,从而修改登录退出的时间 result = mLogout.timeout(id, user_id) #假设会话过期 if result == 0: return handler500(req) url = mTools.getSession(req, 'login_from') mTools.delSession(req, 'login_from') if url is None: url = "/" #重定向到首页 #重定向到来源的url #return HttpResponseRedirect("/") return HttpResponse("1") else: return handler404(req) #404 请求错误
def sure_publish(req): #确认发布 mTools = Tools() user_id = mTools.getSession( req, 'user_id') #调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': content = getFormData(req) #获取表单数据 #content=mTools.getSession(req,'publish_info') #从会话中取出数据 operation_id_modify = mTools.getSession(req, 'operation_id_modify') if operation_id_modify != None: #表示要进行修改发布的有效期的车的信息,在这里需要删除该车,然后重新插入 modify_result_code = mPublish_car.updateData( operation_id_modify, content) #modify_result_code=deletePublishValidTimeCar(operation_id_modify,current_user_phone_number) if modify_result_code == 0: return handler500(req) #修改发布的有效期的车的信息失败 operation_id_againPublish = mTools.getSession( req, 'operation_id_againPublish') if operation_id_againPublish != None: #表示要进行重新发布过期的车的信息,在这里需要删除该车,然后重新插入 againPublish_result_code = mPublish_car.deletePublishInalidTimeCar( operation_id_againPublish) if againPublish_result_code == 0: return handler500(req) #重新发布过期的车的信息失败 else: result_code = mPublish_car.firstPublishInsertData( user_id, content) #插入数据 if result_code == 0: return handler500(req) #发布失败 result_code = mPublish_car.firstPublishInsertData(user_id, content) #插入数据 if result_code == 0: return handler500(req) #发布失败 mTools.delSession(req, 'publish_info') #删除会话 mTools.delSession(req, 'operation_id_modify') mTools.delSession(req, 'operation_id_againPublish') return HttpResponse("1") else: return handler404(req) #404 请求错误
def delete_demand(req, operation_id): if req.method == 'POST': result_code = mMy_demands.deleteMyDemand(operation_id) #调用这个函数来删除我的需求 if result_code == 0: return handler500(req) #删除我的需求失败 elif result_code == 666: return HttpResponse("1") else: return handler404(req) #404 请求错误
def setting_post(request): """ 验证输入的数据是否正确。如果正确返回1,否则返回0。 """ mTools = Tools() user_id = mTools.getSession(request,'user_id')#调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if request.method == "POST": old_password = request.POST.get("oldPassword",None) new_password = request.POST.get("newPassword",None) old_phone_number = request.POST.get("oldPhoneNumber",None) new_phone_number = request.POST.get("newPhoneNumber",None) current_password = request.POST.get("currentPassword",None) newPhoneNumberExist = request.POST.get("newPhoneNumberExist",None) # TODO:验证其中一项信息 if old_password is not None: result_code = mChange_password.checkPassword(user_id, old_password) if result_code == 666: return HttpResponse("1") elif result_code == 0: return handler500(request) if new_password is not None: result_code = mChange_password.changePassword(user_id, new_password) if result_code == 666: return HttpResponse("1") #修改AI手机 if current_password is not None: result_code = mChange_password.checkPassword(user_id, current_password) if result_code == 666: return HttpResponse("1") if old_phone_number is not None: result_code = mChange_phone.checkPhone(old_phone_number) if result_code == 666: return HttpResponse("1") if newPhoneNumberExist is not None: result_code = mChange_phone.newPhoneIsExist(newPhoneNumberExist) if result_code == 666: #查询到存在该手机号 return HttpResponse("2") #该手机号已经被注册 if new_phone_number is not None: result_code = mChange_phone.changePhone(user_id, new_phone_number) if result_code == 666: request.session['phone'] = new_phone_number return HttpResponse("1") return HttpResponse("0") else: return handler404(request)
def get_data_by_one_word_sort(req): if req.method == "GET": condition = getMethodGetParams(req) result_list = mKeyword_search.OneWordGetData(condition) if result_list == 0: return handler500(req) else: req.session['search_datas'] = result_list req.session['length_search_datas'] = len(result_list) return HttpResponseRedirect("/search/")
def deal_records(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": result = mDeal.get_all_deal_records() if result == 0: return handler500(req) else: context = {'deal_record_list': result} return render(req, 'admin/deal_record_home.html', context) else: result = mDeal.get_all_user_info_list() if result == 0: return handler500(req) else: context = {'deal_record_list': result} return render(req, 'admin/deal_record_home.html', context)
def content_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": content_list = mContentHome.content_list() if content_list == 0: return handler500(req) else: context = {"notice": notice, "content_list": content_list} return render(req, 'admin/content/content_list.html', context) result = mContentHome.content_list() if result == 0: return handler500(req) else: context = {'content_list': result} return render(req, 'admin/all_content_home.html', context) else: return handler404(req)
def key_word_sort(req): if req.method == "GET": createSession(req) condition = getDataFromSession(req) #result_list = mKeyword_search.OneWordGetData(condition) result_list = mKeyword_search.keyWordIntersection(condition) if result_list == 0: return handler500(req) else: req.session['search_datas'] = result_list req.session['length_search_datas'] = len(result_list) return HttpResponseRedirect("/search/")
def black_list_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": backlist = mBlackList.get_black_list() if backlist == 0: return handler500(req) else: context = {"notice": notice, "backlist": backlist} return render(req, "admin/member/backlist.html", context) result = mBlackList.get_black_list() if result == 0: return handler500(req) else: context = {'black_list': result} return render(req, 'admin/black_list.html', context) else: return handler404(req)
def collect_seller(req): mTools = Tools() user_id = mTools.getSession( req, 'user_id') #调用account.account_manage模块的类Tools的getSession()函数来获取当前会话的id if user_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'GET': mycollect_records = mCollect_seller.searchCollectSeller( user_id) #调用这个函数来查询收藏的商家 if mycollect_records == 0: return handler500(req) #查询失败 list_content = mCollect_seller.getInFo( mycollect_records) #调用这个函数来处理用户的收藏的商家的信息 if list_content == 0: return handler500(req) #查询失败 context = {"is_login": True, 'list_content': list_content} return render(req, "collection.html", context) else: return handler404(req) #404 请求错误
def modify_vip_in_content(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': state = req.POST.get('check', 0) operation_id = req.POST.get('check', 0) result = mVIP.check_vip(operation_id, state) if result == 0: return handler500(req) elif result == 666: return HttpResponseRedirect('/vipCheckHome/') else: operation_id = req.GET.get('operation_id', 0) result = mVIP.preview_vip(operation_id) if result == 0: return handler500(req) else: context = {'vip_info': result} return render(req, 'admin/modify_vip_in_content.html', context)