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 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 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 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 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 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 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 get_result_search(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'GET': pageType = req.GET.get('pageType', '') curPage = int(req.GET.get('curPage', '1')) allPage = int(req.GET.get('allPage', '1')) user_infos_piece = mTools.getSession(req, 'search_datas') length_user_infos_piece = mTools.getSession(req, 'length_search_datas') data = mAdmin_search.searchPaging(user_infos_piece, length_user_infos_piece, curPage, allPage, pageType) return data else: return handler404(req)
def admin_logout(req): mAdmin_tools = Admin_tools() admin_id = mAdmin_tools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': action = req.POST.get('action', '0') if action == '1': admin_login_id = mAdmin_tools.getSession(req, 'admin_login_id') result_code = mLogout.logout(admin_login_id, admin_id) if result_code == 0: return handler500(req) elif result_code == 666: mAdmin_tools.delSession(req, 'admin_id') mAdmin_tools.delSession(req, 'admin_login_id') return HttpResponse("1") #return HttpResponseRedirect("/adminLogin/") else: return HttpResponse("0") else: return handler404(req)
def black_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 == 'GET': operation_id = req.GET.get('operation_id', 0) result = mVIP.black_vip(operation_id) if result == 0: return handler500(req) elif result == 666: return HttpResponseRedirect('/allVipHome/') else: return handler404(req)
def set_super_admin_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": result = mSet_admin.find_not_super_admins() if result == 0: return handler500(req) else: context = {'admin_infos_list': result} return render(req, 'admin/set_super_admin.html', context) else: return handler404(req)
def set_super_admin(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'GET': operation_id = req.GET.get('operation_id', 0) result = mSet_admin.set_super_admin(operation_id) if result == 0: return handler500(req) elif result == 666: return HttpResponseRedirect('/setSuperAdminHome/') else: return handler404(req)
def delete_admin(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == 'POST': operation_id = req.POST.get('id', 0) result = mSet_admin.delete_admin(operation_id) if result == 0: return HttpResponse("0") #删除该管理员失败 #return handler500(req) elif result == 666: return HttpResponse("1") #删除该管理员成功 else: return handler404(req)
def vip_check_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": context = {"notice": notice} return render(req, "admin/member/member_audit.html", context) result = mVIP.get_vip_list() if result == 0: return handler500(req) else: context = {'vip_list': result} return render(req, 'admin/vip_home.html', context) else: return handler404(req)
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 admin_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": context = {"notice": notice} return render(req, 'admin/common/base.html', context) result = mHome.is_super_admin(admin_id) if result == 0: return handler500(req) elif result == 1: is_super_admin = False else: is_super_admin = True context = {'is_super_admin': is_super_admin} return render(req, 'admin/home.html', context) else: return handler404(req)
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 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 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)
def set_admin_home(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": result = mSet_admin.search_admin_account() if result == 0: return handler500(req) else: context = {"notice": notice, "administrator_list": result} return render(req, 'admin/setting/administrator_setting.html', context) result = mSet_admin.search_admin_account() if result == 0: return handler500(req) else: context = {'admin_infos_list': result} return render(req, 'admin/set_admin_home.html', context) else: return handler404(req)
def view_search(req): mTools = Admin_tools() admin_id = mTools.getSession(req, 'admin_id') if admin_id is None: return HttpResponseRedirect('/sessionExceedTime/') if req.method == "GET": data = get_result_search(req) merchant_id_list = data.get('results', '') allPage = data.get('allPage', '1') #总页数 curPage = data.get('curPage', '1') #获取处理后的当前页数 user_infos_piece = mAdmin_search.findMerchant(merchant_id_list) context = { "allPage": allPage, "curPage": curPage, "result_list": user_infos_piece } return context #返回所需要的数据 #return render(req, template, context) else: return handler404(req)
def delete_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 == 'GET': delete_type = req.GET.get('delete_type', '0') if delete_type == '0': #一个个删除 operation_id = req.GET.get('operation_id', 0) result = mContentHome.delete_vip_one_by_one(operation_id) elif delete_type == '1': #批量删除 operation_id_list = req.GET.getlist("operationIdList[]") result = mContentHome.delete_vip_some(operation_id_list) else: #全部删除 result = mContentHome.delete_vip_all() if result == 0: return handler500(req) elif result == 666: return HttpResponseRedirect('/contentHome/') else: return handler404(req)