def get(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) return render(request, 'ban/ban_edit.html', { u'servers': Server.objects.all(), u'active_menu': u'ban_edit' })
def get(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) form = ServerViewForm() return render(request, 'server.html', { u'active_menu': u'server', u'form': form })
def notice(request): if not request.user.is_authenticated(): return login(request) if request.method == 'POST': content = request.POST.get('notice_content', '') query_name = request.POST.get('hidden_query_name', '') if query_name is None: print("query_name is nil") return ret, reason = util.execute_notice(query_name, content) if ret: now = timezone.now() record = NoticeRecord.objects.create(result=reason, author=request.user.username, content=content, create_date=now, send_date=now, server_group=query_name, sended=True) record.save() return render(request, 'notice_send.html', {}) else: names = util.get_notice_names(request) rsp_content = { 'active_menu': 'notice', 'user': request.user, 'notice_names': names, 'query_name': query_name, 'content_list': content, 'error': reason, } return render(request, 'notice.html', rsp_content) names = util.get_notice_names(request) query_name = request.GET.get('query_name', names[0]) content_list = util.get_notice_content(query_name) content = { 'active_menu': 'notice', 'user': request.user, 'notice_names': names, 'query_name': query_name, 'content_list': content_list, } return render(request, 'notice.html', content)
def get(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) limit = 15 # 每页显示的记录数 groups = GameMailRecordGroup.objects.order_by('-send_date') paginator = Paginator(groups, limit) # 实例化一个分页对象 page = request.GET.get('page', 1) # 获取页码 try: ret = paginator.page(page) # 获取某页对应的记录 except PageNotAnInteger: # 如果页码不是个整数 ret = paginator.page(1) # 取第一页的记录 except EmptyPage: # 如果页码太大,没有相应的记录 ret = paginator.page(paginator.num_pages) # 取最后一页的记录 return render(request, 'gamemail/gamemail_list.html', {'page': ret, 'active_menu': "gamemail"})
def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) form = ServerViewForm(request.POST) if form.is_valid(): op_id = form.cleaned_data['op'] param = form.cleaned_data['param'] server_ids = form.cleaned_data['server'] servers = [] for iter_id in server_ids: server = Server.objects.get(id=iter_id) servers.append(server) ret = eval('depoly_gm.' + op_id)(servers, param) form.result = ret return render(request, 'server.html', { u'active_menu': u'server', u'form': form })
def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) form = GameMailViewForm(request.POST) if form.is_valid(): send_date = form.cleaned_data['send_date'] server_ids = form.cleaned_data['server_list'] title = form.cleaned_data['title'] content = form.cleaned_data['message'] accounts = request.POST.get('accounts', '') is_whole_accounts = (request.POST.get('whole_accounts', '') == u'on') if not is_whole_accounts and accounts == u'': return HttpResponseForbidden() now = timezone.now() record = GameMailRecordGroup.objects.create(gm=request.user.gm, title=title, content=content, is_to_whole_accounts=is_whole_accounts, create_date=now, send_date=send_date, sended=False) record.save() # mails for iter_id in server_ids: server = Server.objects.get(id=iter_id) mail = GameMailRecord.objects.create(server=server, group=record) mail.save() # accs hidden_items_json = request.POST.get('hidden_items', '') hidden_items = json.loads(hidden_items_json, encoding='utf8') for item in hidden_items: acc = GameMailAccRecord.objects.create(item_id=item.get(u'item_id'), num=item.get(u'num'), item_type=item.get(u'item_type'), group=record) acc.save() # targets target_accounts = accounts.split(",") for account in target_accounts: target = GameMailTargetAccountRecord.objects.create(account=account, group=record) target.save() on_mailgroup_create(record) return HttpResponseRedirect('/gamemail_send') return render(request, 'gamemail/gamemail.html', {'form': form, 'active_menu': "gamemail"})
def post(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) account = int(request.POST.get('account', '')) reason = request.POST.get('reason', '') hour = int(request.POST.get('time', '')) str_server = request.POST.get('server', '') id_server = int(str_server) second = hour * 60 * 60 ban_type = request.POST.get('ban_type', '') if ban_type not in self.ban_types: return HttpResponseForbidden() obj = {'actor_rid': account, 'msg_id': ban_type, 'time': second} ret = Send2GMServer(obj, id_server) if ret == 1: messages.success(request, '发送成功') now = timezone.now() record = BanRecord.objects.create(ret=str(ret), account=str(account), reason=reason, time=second, create_date=now, type=ban_type, gm=request.user.gm) record.save() else: messages.warning(request, '发送失败,错误码:' + str(ret)) return render(request, 'ban/ban_edit.html', { u'servers': Server.objects.all(), u'active_menu': u'ban_edit' })
def notice_list(request): if not request.user.is_authenticated(): return login(request) request.session['admin_entry'] = "/notice" request.session.modified = True return HttpResponseRedirect('/admin/notice/noticerecord/')
def get(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) form = GameMailViewForm() return render(request, 'gamemail/gamemail.html', {'form': form, 'active_menu': "gamemail"})
def get(self, request, *args, **kwargs): if not request.user.is_authenticated(): return login(request) request.session['admin_entry'] = "/ban_edit" request.session.modified = True return HttpResponseRedirect('/admin/ban/banrecord/')