def backend_userlist(request): '''返回所有用户的View''' obj = User.objects.all().order_by('-date_joined') page_num = 15 context = Page_List_View(request, obj, page_num).get_page_context() try: registerinfo = request.session['registerinfo'] del request.session['registerinfo'] context.update({'registerinfo': registerinfo}) except: pass return render(request, 'backend/userlist.html', context=context)
def backend_charge(request): '''后台充值码界面''' # 获取所有充值码记录 obj = MoneyCode.objects.all() page_num = 10 context = Page_List_View(request, obj, page_num).get_page_context() registerinfo = request.session.get('registerinfo') if registerinfo: context['registerinfo'] = registerinfo del request.session['registerinfo'] # 获取充值的金额和数量 Num = request.GET.get('num') money = request.GET.get('money') if Num and money: for i in range(int(Num)): code = MoneyCode(number=money) code.save() registerinfo = { 'title': '成功', 'subtitle': '添加{}元充值码{}个'.format(money, Num), 'status': 'success' } request.session['registerinfo'] = registerinfo return redirect('/sspanel/backend/charge') return render(request, 'backend/charge.html', context=context)
def backend_alive_user(request): user_list = [] for node_id in Node.get_node_ids_by_show(): user_list.extend(AliveIp.recent_alive(node_id)) page_num = 15 context = Page_List_View(request, user_list, page_num).get_page_context() return render(request, "backend/aliveuser.html", context=context)
def user_delete(request, pk): '''删除user''' user = User.objects.filter(pk=pk) user.delete() obj = User.objects.all() page_num = 15 context = Page_List_View(request, obj, page_num).get_page_context() registerinfo = { 'title': '删除用户', 'subtitle': '成功啦', 'status': 'success', } context['registerinfo'] = registerinfo return render(request, 'backend/userlist.html', context=context)
def backend_charge(request): '''后台充值码界面''' # 获取所有充值码记录 obj = MoneyCode.objects.all() page_num = 10 context = Page_List_View(request, obj, page_num).get_page_context() # 获取充值的金额和数量 Num = request.GET.get('num') money = request.GET.get('money') if Num and money: for i in range(int(Num)): code = MoneyCode(number=money) code.save() messages.success(request, '添加{}元充值码{}个'.format( money, Num), extra_tags="成功") return HttpResponseRedirect(reverse('sspanel:backend_charge')) return render(request, 'backend/charge.html', context=context)
def purchase_history(request): """购买历史""" obj = PurchaseHistory.objects.all() page_num = 10 context = Page_List_View(request, obj, page_num).get_page_context() return render(request, "backend/purchasehistory.html", context=context)
def backend_userlist(request): """返回所有用户的View""" obj = User.objects.all().order_by("-date_joined") page_num = 15 context = Page_List_View(request, obj, page_num).get_page_context() return render(request, "backend/userlist.html", context)
def backend_userlist(request): '''返回所有用户的View''' obj = User.objects.all().order_by('-date_joined') page_num = 15 context = Page_List_View(request, obj, page_num).get_page_context() return render(request, 'backend/userlist.html', context)