Ejemplo n.º 1
0
def updata_password(request):
    #更新admin密码
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    passwd = request.POST.get('password')
    re_passwd = request.POST.get('re_password')

    if btn_lst:

        if request.method == 'POST':
            if passwd != re_passwd:
                #2次密码不对 返回页面重新输入
                return render_to_response("auth/change_admin_info.html", {'erro':u'2次密码不一致,请重新输入'}, RequestContext(request))
            else:
                #2次密码正确 扔数据库
                _gm = GameManager()
                _gm.password = passwd
                mysql_game_manager.update_admin_password(_gm)
                # 操作日志记录
                insert_action_update_password(_gm)
                return HttpResponseRedirect('Tyranitar6/updata_password/')
        else:
            return render_to_response("base/base.html", {'account':manager.account,'btn_lst':btn_lst}, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 2
0
def updata_password(request):
    #更新admin密码
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    passwd = request.POST.get('password')
    re_passwd = request.POST.get('re_password')

    if btn_lst:

        if request.method == 'POST':
            if passwd != re_passwd:
                #2次密码不对 返回页面重新输入
                return render_to_response("auth/change_admin_info.html",
                                          {'erro': u'2次密码不一致,请重新输入'},
                                          RequestContext(request))
            else:
                #2次密码正确 扔数据库
                _gm = GameManager()
                _gm.password = passwd
                mysql_game_manager.update_admin_password(_gm)
                # 操作日志记录
                insert_action_update_password(_gm)
                return HttpResponseRedirect('Tyranitar6/updata_password/')
        else:
            return render_to_response("base/base.html", {
                'account': manager.account,
                'btn_lst': btn_lst
            }, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 3
0
def updata_admin_password(request):
    """
        修改管理员密码
    """
    passwd = request.POST.get('password')
    re_passwd = request.POST.get('re_password')
    uid = request.POST.get('id')
    if request.method == 'POST':
        if passwd != re_passwd:
            # 2次密码不对 返回页面重新输入
            return render_to_response("auth/change_admin_password.html",
                                      {'erro': u'2次密码不一致,请重新输入'},
                                      RequestContext(request))
        else:
            # 2次密码正确 扔数据库
            _gm = GameManager()
            _gm.password = passwd
            _gm.uid = uid
            mysql_game_manager.update_admin_password(_gm)
            # 操作日志记录
            insert_action_update_password(_gm)
            return HttpResponseRedirect('/Tyranitar6/login/')
    else:
        return render_to_response("auth/super_manage.html", {},
                                  RequestContext(request))
Ejemplo n.º 4
0
def accept_post(request):
    from apps.game_manager.views import data_edit
    '''
    处理 JQ AJAX Post请求
    data_edit
    视图包 处理函数 不能删哦。
    '''
    value_dict = {}

    if request.is_ajax():
        value_dict['user_id'] = request.POST.get('user_id')
        value_dict['item_id'] = request.POST.get('item_id')
        value_dict['server_id'] = request.POST.get('server_id')
        value_dict['value'] = request.POST.get('value')
        value_dict['input_value'] = request.POST.get('input_value')
        value_dict['function_name'] = request.POST.get('function_name')
        value_dict['manager'] = GameManager.get_by_request(request)
        result = eval(value_dict['function_name'])(value_dict)
        if result :
            json_data = {
                'value': value_dict['input_value'],
            }
        else:
            json_data = {
                'value': value_dict['value'],
            }
        return HttpResponse(json.dumps(json_data), content_type='application/json')
Ejemplo n.º 5
0
def select_account(request):
    """
        超级管理员授权管理
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:

        head_lst = [
            {'width': 20, 'name': u'ID'},
            {'width': 50, 'name': u'帐号'},
            {'width': 50, 'name': u'名字'},
            {'width': 50, 'name': u'权限'},
            {'width': 50, 'name': u'最后登录IP'},
            {'width': 50, 'name': u'最后登录时间'},
            {'width': 50, 'name': u'描述'},
            {'width': 50, 'name': u'操作'},
            ]

        if request.method == 'POST':
            return render_to_response('auth/super_manage.html', {'account':manager.account,'btn_lst':btn_lst,'head_lst': head_lst},RequestContext(request))
        else:
            row_lst = administrators_information.get_table()
            return render_to_response('auth/super_manage.html',{'account':manager.account,'btn_lst':btn_lst,'head_lst': head_lst,'row_lst':row_lst}, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 6
0
def accept_post(request):
    from apps.game_manager.views import data_edit
    '''
    处理 JQ AJAX Post请求
    data_edit
    视图包 处理函数 不能删哦。
    '''
    value_dict = {}

    if request.is_ajax():
        value_dict['user_id'] = request.POST.get('user_id')
        value_dict['item_id'] = request.POST.get('item_id')
        value_dict['server_id'] = request.POST.get('server_id')
        value_dict['value'] = request.POST.get('value')
        value_dict['input_value'] = request.POST.get('input_value')
        value_dict['function_name'] = request.POST.get('function_name')
        value_dict['manager'] = GameManager.get_by_request(request)
        result = eval(value_dict['function_name'])(value_dict)
        if result:
            json_data = {
                'value': value_dict['input_value'],
            }
        else:
            json_data = {
                'value': value_dict['value'],
            }
        return HttpResponse(json.dumps(json_data),
                            content_type='application/json')
Ejemplo n.º 7
0
def view_index(request):
    _gm = GameManager.get_by_request(request)
    if _gm:
        return render_to_response('auth/change_admin_password.html',
                                  {'id': _gm.uid})
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 8
0
def update_user(request):
    """
        修改信息页面
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()

    #接收 修改的数据
    #帐号  名字  权限 描述
    if btn_lst:
        account = request.POST.get('account')
        name = request.POST.get('name')
        permission_name = request.POST.get('permission')
        description = request.POST.get('description')
        permission_list = game_manage_define.MANAGER_PERMISSION[1:]
        return render_to_response(
            "auth/change_admin_info.html", {
                'btn_lst': btn_lst,
                'account': account,
                'name': name,
                'permission_name': permission_name,
                'description': description,
                'permission_list': permission_list
            }, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 9
0
def add_admin(request):
    """
        管理员注册
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]
    if btn_lst:
        if request.method == "POST":
            account = request.POST.get('account')
            password = request.POST.get('password')
            re_password = request.POST.get('re_password')
            name = request.POST.get('name')
            description = request.POST.get('description')
            permission = request.POST.get('permission')

            if password != re_password:

                return render_to_response("auth/register_user.html", {'btn_lst':btn_lst,'permission_list':permission_list}, RequestContext(request))
            else:
                _gm = GameManager()
                _gm.account = account
                _gm.password = password
                _gm.name = name
                _gm.permissions = permission
                _gm.description = description
                mysql_game_manager.insert_game_manager(_gm)
                # 操作日志记录
                insert_action_manager_register(_gm)
                return HttpResponseRedirect('/Tyranitar6/super_man/select_account/')
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 10
0
def update_data(request):
    """
        更新admin信息
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]
    account = request.POST.get('account')
    name = request.POST.get('name')
    permission_name = request.POST.get('permission')
    description = request.POST.get('description')
    if btn_lst:
        if request.method == 'POST':
            #2次密码正确 扔数据库
            _gm = GameManager()
            _gm.account = account
            _gm.name = name
            _gm.permissions = permission_name
            _gm.description = description
            mysql_game_manager.update_game_infomation(_gm)
            # 操作日志记录
            insert_action_update_manager_info(manager, account, name,
                                              permission_name, description)
            return HttpResponseRedirect(
                '/Tyranitar6/super_man/select_account/')
        else:
            return render_to_response("auth/super_manage.html",
                                      {'btn_lst': btn_lst},
                                      RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 11
0
def register(request):
    """
        超级管理员注册
    """
    super_manager = mysql_game_manager.get_super_manager()
    if not super_manager:
        if request.method == "POST":
            account = request.POST.get('account')
            password = request.POST.get('password')
            re_password = request.POST.get('re_password')
            name = request.POST.get('name')
            description = request.POST.get('description')

            if password != re_password:
                return render_to_response("auth/register.html", {'status': 1},
                                          RequestContext(request))
            else:
                _gm = GameManager()
                _gm.account = account
                _gm.password = password
                _gm.name = name
                _gm.description = description
                _gm.permissions = 'Super'
                mysql_game_manager.insert_game_manager(_gm)
                # 操作日志记录
                insert_action_super_manager_register(_gm)
                return HttpResponseRedirect(game_manage_define.MAIN_URL)
        else:
            return render_to_response("auth/register.html", {},
                                      RequestContext(request))
    else:
        return HttpResponseRedirect(game_manage_define.MAIN_URL + "/login/")
Ejemplo n.º 12
0
def get_game_manager(account):
    """
        获取游戏管理员账号
    """
    sql = "SELECT * FROM admin_manager WHERE account='%s'" % account
    data = get_game_manager_mysql_connection().get(sql)
    if data:
        _gm = GameManager()
        _gm.uid = data['id']
        _gm.account = data['account']
        _gm.password = data["password"]
        _gm.name = data["name"]
        _gm.description = data["description"]
        _gm.permissions = data["permissions"]
        _gm.last_login_ip = data["last_login_ip"]
        _gm.last_login_time = data["last_login_time"]
        return _gm
    else:
        return None
Ejemplo n.º 13
0
def get_game_manager_with_id(manager_id):
    """
        用ID 获取管理员
    """
    sql = "SELECT * FROM admin_manager WHERE id=%s" % manager_id
    data = get_game_manager_mysql_connection().get(sql)
    if data:
        _gm = GameManager()
        _gm.uid = data['id']
        _gm.account = data['account']
        _gm.password = data["password"]
        _gm.name = data["name"]
        _gm.description = data["description"]
        _gm.permissions = data["permissions"]
        _gm.last_login_ip = data["last_login_ip"]
        _gm.last_login_time = data["last_login_time"]
        return _gm
    else:
        return None
Ejemplo n.º 14
0
def get_super_manager():
    """
        获取超级管理员
    """
    sql = "SELECT * FROM admin_manager WHERE permissions='%s'" % str('Super')
    data = get_game_manager_mysql_connection().get(sql)
    if data:
        _gm = GameManager()
        _gm.uid = data['id']
        _gm.account = data['account']
        _gm.username = data["password"]
        _gm.name = data["name"]
        _gm.description = data["description"]
        _gm.permissions = data["permissions"]
        _gm.last_login_ip = data["last_login_ip"]
        _gm.last_login_time = data["last_login_time"]
        print("super = "  + str(_gm))
        return _gm
    else:
        return None
Ejemplo n.º 15
0
 def wrapped_view_func(request, *args, **kwargs):
     path = request.path
     game_manager = GameManager.get_by_request(request)
     if game_manager is None:
         return HttpResponseRedirect("/Tyranitar6/login/")
     # 查询权限
     if not game_manager.is_allow(path):
         return HttpResponseRedirect("/Tyranitar6/login/")
     else:
         re = view_func(request, *args, **kwargs)
         return re
Ejemplo n.º 16
0
 def wrapped_view_func(request, *args, **kwargs):
     path = request.path
     game_manager = GameManager.get_by_request(request)
     if game_manager is None:
         return HttpResponseRedirect("/Tyranitar6/login/")
     # 查询权限
     if not game_manager.is_allow(path):
         return HttpResponseRedirect("/Tyranitar6/login/")
     else:
         re = view_func(request, *args, **kwargs)
         return re
Ejemplo n.º 17
0
def register(request):
    """
        超级管理员注册
    """
    super_manager = mysql_game_manager.get_super_manager()
    if not super_manager:
        if request.method == "POST":
            account = request.POST.get('account')
            password = request.POST.get('password')
            re_password = request.POST.get('re_password')
            name = request.POST.get('name')
            description = request.POST.get('description')

            if password != re_password:
                return render_to_response("auth/register.html", {'status': 1}, RequestContext(request))
            else:
                _gm = GameManager()
                _gm.account = account
                _gm.password = password
                _gm.name = name
                _gm.description = description
                _gm.permissions = 'Super'
                mysql_game_manager.insert_game_manager(_gm)
                # 操作日志记录
                insert_action_super_manager_register(_gm)
                return HttpResponseRedirect(game_manage_define.MAIN_URL)
        else:
            return render_to_response("auth/register.html", {}, RequestContext(request))
    else:
        return HttpResponseRedirect(game_manage_define.MAIN_URL + "/login/")
Ejemplo n.º 18
0
def update_data(request):
    """
        更新admin信息
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]
    account = request.POST.get('account')
    name = request.POST.get('name')
    permission_name = request.POST.get('permission')
    description = request.POST.get('description')
    if btn_lst:
        if request.method == 'POST':
            #2次密码正确 扔数据库
            _gm = GameManager()
            _gm.account = account
            _gm.name = name
            _gm.permissions = permission_name
            _gm.description = description
            mysql_game_manager.update_game_infomation(_gm)
            # 操作日志记录
            insert_action_update_manager_info(manager, account, name, permission_name, description)
            return HttpResponseRedirect('/Tyranitar6/super_man/select_account/')
        else:
            return render_to_response("auth/super_manage.html", {'btn_lst':btn_lst}, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 19
0
def register_user(request):
    """
        返回一个页面
    """
    #回传一个权限列表
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]

    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:
        return render_to_response('auth/register_user.html',{'account':manager.account,'btn_lst':btn_lst,'permission_list':permission_list})
    else:
        return HttpResponseRedirect('login/')
def processor(request):
    """
        内容的processor
    """
    game_manager = GameManager.get_by_request(request)
    if game_manager:
        btn_lst = game_manager.check_admin_permission()
        try:
            path = request.path.split('/')[2]
        except:
            pass
        return {'btn_lst': btn_lst, 'permissions':game_manager.permissions,'account': game_manager.account, 'path':path }
    return {}
Ejemplo n.º 21
0
    def wrapped_view_func(request, *args, **kwargs):
        path = request.path
        moderator = GameManager.get_by_request(request)

        # # 管理员信息失效
        if moderator is None:
            return HttpResponseRedirect("/Tyranitar6/login/")
        # 查询权限
        if not moderator.is_allow(path):
            return HttpResponseRedirect("/Tyranitar6/login/")
        else:
            re = view_func(request, *args, **kwargs)
            return re
Ejemplo n.º 22
0
    def wrapped_view_func(request, *args, **kwargs):
        path = request.path
        moderator = GameManager.get_by_request(request)

        # # 管理员信息失效
        if moderator is None:
            return HttpResponseRedirect("/Tyranitar6/login/")
        # 查询权限
        if not moderator.is_allow(path):
            return HttpResponseRedirect("/Tyranitar6/login/")
        else:
            re = view_func(request, *args, **kwargs)
            return re
Ejemplo n.º 23
0
def updata_admin_password(request):
    """
        修改管理员密码
    """
    passwd = request.POST.get('password')
    re_passwd = request.POST.get('re_password')
    uid = request.POST.get('id')
    if request.method == 'POST':
        if passwd != re_passwd:
            # 2次密码不对 返回页面重新输入
            return render_to_response("auth/change_admin_password.html", {'erro': u'2次密码不一致,请重新输入'},
                                      RequestContext(request))
        else:
            # 2次密码正确 扔数据库
            _gm = GameManager()
            _gm.password = passwd
            _gm.uid = uid
            mysql_game_manager.update_admin_password(_gm)
            # 操作日志记录
            insert_action_update_password(_gm)
            return HttpResponseRedirect('/Tyranitar6/login/')
    else:
        return render_to_response("auth/super_manage.html", {}, RequestContext(request))
Ejemplo n.º 24
0
def delete_monster(request):
    """
        删除宠物
    """
    manager = GameManager.get_by_request(request)
    if request.method == "POST":
        user_id = str(request.POST.get("user_id"))
        server_id = str(request.POST.get("server_id"))
        monster_uid = str(request.POST.get("monster_uid"))
        starLevel = str(request.POST.get("starLevel"))
        level = str(request.POST.get("level"))
        remove_monster(manager, user_id, server_id, monster_uid, starLevel, level)
        return HttpResponseRedirect("/Tyranitar6/data_edit/monster_info_edit/")
    else:
        return render_to_response("data_edit/add_monster.html", RequestContext(request))
Ejemplo n.º 25
0
def delete_monster(request):
    """
        删除宠物
    """
    manager = GameManager.get_by_request(request)
    if request.method == 'POST':
        user_id = str(request.POST.get('user_id'))
        server_id = str(request.POST.get('server_id'))
        monster_uid = str(request.POST.get('monster_uid'))
        starLevel = str(request.POST.get('starLevel'))
        level = str(request.POST.get('level'))
        remove_monster(manager, user_id, server_id, monster_uid, starLevel,
                       level)
        return HttpResponseRedirect('/Tyranitar6/data_edit/monster_info_edit/')
    else:
        return render_to_response("data_edit/add_monster.html",
                                  RequestContext(request))
def processor(request):
    """
        内容的processor
    """
    game_manager = GameManager.get_by_request(request)
    if game_manager:
        btn_lst = game_manager.check_admin_permission()
        try:
            path = request.path.split('/')[2]
        except:
            pass
        return {
            'btn_lst': btn_lst,
            'permissions': game_manager.permissions,
            'account': game_manager.account,
            'path': path
        }
    return {}
Ejemplo n.º 27
0
def delete_user(request):
    """
        删除一个管理员
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()

    if btn_lst:
        if request.method == 'POST':
            del_id = request.POST.get('id')
            mysql_game_manager.del_admin_by_id(del_id)
            # 操作日志记录
            insert_action_delete_manager(manager, del_id)
            return HttpResponseRedirect('/Tyranitar6/super_man/select_account/')
        else:
            return HttpResponseRedirect('/Tyranitar6/super_man/select_account/')
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 28
0
def register_user(request):
    """
        返回一个页面
    """
    #回传一个权限列表
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]

    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:
        return render_to_response(
            'auth/register_user.html', {
                'account': manager.account,
                'btn_lst': btn_lst,
                'permission_list': permission_list
            })
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 29
0
def get_game_manager(account):
    """
        获取游戏管理员账号
    """
    sql = "SELECT * FROM admin_manager WHERE account='%s'" % account
    data = get_game_manager_mysql_connection().get(sql)
    if data:
        _gm = GameManager()
        _gm.uid = data['id']
        _gm.account = data['account']
        _gm.password = data["password"]
        _gm.name = data["name"]
        _gm.description = data["description"]
        _gm.permissions = data["permissions"]
        return _gm
    else:
        return None
Ejemplo n.º 30
0
def delete_user(request):
    """
        删除一个管理员
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()

    if btn_lst:
        if request.method == 'POST':
            del_id = request.POST.get('id')
            mysql_game_manager.del_admin_by_id(del_id)
            # 操作日志记录
            insert_action_delete_manager(manager, del_id)
            return HttpResponseRedirect(
                '/Tyranitar6/super_man/select_account/')
        else:
            return HttpResponseRedirect(
                '/Tyranitar6/super_man/select_account/')
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 31
0
def add_admin(request):
    """
        管理员注册
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    permission_list = game_manage_define.MANAGER_PERMISSION[1:]
    if btn_lst:
        if request.method == "POST":
            account = request.POST.get('account')
            password = request.POST.get('password')
            re_password = request.POST.get('re_password')
            name = request.POST.get('name')
            description = request.POST.get('description')
            permission = request.POST.get('permission')

            if password != re_password:

                return render_to_response("auth/register_user.html", {
                    'btn_lst': btn_lst,
                    'permission_list': permission_list
                }, RequestContext(request))
            else:
                _gm = GameManager()
                _gm.account = account
                _gm.password = password
                _gm.name = name
                _gm.permissions = permission
                _gm.description = description
                mysql_game_manager.insert_game_manager(_gm)
                # 操作日志记录
                insert_action_manager_register(_gm)
                return HttpResponseRedirect(
                    '/Tyranitar6/super_man/select_account/')
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 32
0
def update_user(request):
    """
        修改信息页面
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()

    #接收 修改的数据
    #帐号  名字  权限 描述
    if btn_lst:
        account = request.POST.get('account')
        name = request.POST.get('name')
        permission_name = request.POST.get('permission')
        description = request.POST.get('description')
        permission_list = game_manage_define.MANAGER_PERMISSION[1:]
        return render_to_response("auth/change_admin_info.html", {'btn_lst':btn_lst,
                                                                  'account':account,
                                                                  'name':name,
                                                                  'permission_name':permission_name,
                                                                  'description':description,
                                                                  'permission_list':permission_list}, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 33
0
def set_player_data(request):
    # 获取管理员信息
    manager = GameManager.get_by_request(request)
    head_lst = [
        #{'width': 50, 'name': u'UID'},
        {
            'width': 50,
            'name': u'名称'
        },
        {
            'width': 50,
            'name': u'当前值'
        },
        {
            'width': 50,
            'name': u'修改'
        },
    ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        print request.POST, 'post'
        user_id = request.POST.get('user_id')
        server_id = int(request.POST.get('server_id'))
        typ = request.POST.get('type')
        value = request.POST.get('value')
        #print 'value',value
        if value <> '':
            if typ <> 'str':
                if typ == 'bool':
                    value = eval(typ)(eval(value))
                else:
                    value = eval(typ)(value)
                #print value
        key = request.POST.get('key')
        data = ''
        if key == 'newbie':
            # print 'newbie'
            # print int(value)
            # print get_newbie_phase_config(int(value))
            if get_newbie_phase_config(int(value)) == None:
                data = '新手引导ID应在1~5之间'
        elif key == 'gold':
            pass
        elif key == 'champion_index':
            if int(value) not in [1, 2, 3, 4, 0]:
                data = '冠军宠物位置应该在0~4之间'
        elif key == 'reward_cur_monster_star_level_id':
            if get_reward_monster_star_level_config(int(value)) == None:
                data = u'宠物等级奖励序列应在1~18之间'
        elif key == 'universal_fragment':
            pass
        elif key == 'title':
            if get_the_title_config(int(value)) == None:
                data = '玩家爵位应在1~21之间'
        elif key == 'consumption_point':
            pass
        elif key == 'role_id':
            pass
        elif key == 'reward_login_series_id':
            pass
        elif key == 'reward_cur_monster_kind_id':
            if get_reward_monster_kind_config(int(value)) == None:
                data = '宠物种类奖励序列应在1~18之间'
        elif key == 'has_first_recharge_lst':
            pass
        elif key == 'is_stone_one_draw':
            if int(value) not in [0, 1]:
                data = '首次钻石单抽状态取值应为0或1,0代表未抽过,1代表抽过'
        elif key == 'is_ten_draw':
            if int(value) not in [0, 1]:
                data = '首次钻石十连抽状态取值应为0或1,0代表未抽过,1代表抽过'
        elif key == 'champion_tid':
            cmem_url = server_define.CMEM_MAP[int(server_id)]
            source = memcache.get_cmem_val(
                cmem_url, model_define.MONSTER_MODEL.format(user_id=user_id))
            # print source['monsters']
            sign = 0
            for i in source['monsters']:
                if int(value) == i['tid']:
                    sign = 1
            # print sign
            if sign == 0:
                data = u'输入的宠物id不属于玩家拥有的宠物之一,请正确输入,玩家现有宠物:'
                for i in source['monsters']:
                    a = '(%s:%s)' % (i['tid'], get_monster_config(
                        i['tid'])['name'])
                    data += a
        elif key == 'champion_power':
            pass
        elif key == 'name':
            pass
        elif key == 'level':
            if int(value) > 120 or int(value) < 1:
                data = u'玩家等级应在1~120级之间,请输入正确的值'
        elif key == 'cur_stage':
            if get_stages_config(int(value)) == None:
                data = u'关卡ID输入错误'
        elif key == 'reward_cur_monster_quality_id':
            if get_reward_monster_quality_config(int(value)) == None:
                data = u'当前宠物品质奖励序列应在1~3之间'
        elif key == 'reward_cur_team_combat_power_id':
            if get_reward_team_power(int(value)) == None:
                data = u'当前队伍战斗力奖励序列应在1~47之间'
        elif key == 'reward_friend_num_id':
            if get_fried_num_config(int(value)) == None:
                data = u'好友数量奖励序列应在1~6之间'
        elif key == 'reward_cur_monster_level_id':
            if get_reward_monster_level_config(int(value)) == None:
                data = u'宠物等级奖励序列应在1~10之间'

        if value <> '' and data == '':
            # print "i'work"
            cmem_url = server_define.CMEM_MAP[int(server_id)]
            if cmem_url:
                source = memcache.get_cmem_val(
                    cmem_url,
                    model_define.PLAYER_MODEL.format(user_id=user_id))
                if eval(typ) == type(value) or (typ == 'str'
                                                and type(value) == unicode):
                    #print source,key,value,user_id,type(user_id)
                    old_value = source[key]
                    source[key] = value
                    memcache.put_cmem_val(
                        cmem_url,
                        model_define.PLAYER_MODEL.format(user_id=user_id),
                        source)
                    # 操作日志记录
                    insert_action_edit_player(manager, str(server_id),
                                              str(user_id), key, old_value,
                                              value)
        return HttpResponse(data)
Ejemplo n.º 34
0
def add_monster(request):
    """
        增加宠物数据
        {'generation': 1,  'star_level_rate': 0.02083, 'createTime': datetime.datetime(2015, 5, 31, 9, 12, 51, 761554)}

        evo_level 4 <type 'int'>
        star_level_exp 16 <type 'int'>
        skillsExp [0, 0] <type 'list'>
        level 54 <type 'int'>
        playerID 1000095298 <type 'str'>
        effort 2 <type 'int'>
        starLevel 3 <type 'int'> "4"
        sex 0 <type 'int'>
        generation 1 <type 'int'>
        individual [1, 0, 1, 0, 0, 0] <type 'list'>
        evo_sun_stone 96 <type 'int'>
        skillsLevel [6, 10] <type 'list'>
        exp 11739 <type 'int'>
        personality 11 <type 'int'>
        tid 25 <type 'int'>
        uid 1 <type 'int'>
        star_level_rate 0.02083 <type 'float'>
        maxLevel 60 <type 'int'>
        createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'>
        evo_fail_count 0 <type 'int'>
    """
    manager = GameManager.get_by_request(request)
    if request.method == 'GET':
        user_id = request.GET.get('user_id')
        server_id = request.GET.get('server_id')
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        # 获取宠物tid和名字对应列表
        monster_id_name = game_config.get_monster_config_with_id_name()
        monster_id_name_lst = []
        for (tid, name) in monster_id_name.items():
            content = dict()
            content['tid'] = tid
            content['name'] = name + "_" + str(tid)
            monster_id_name_lst.append(content)
        monster_id_name_lst = sorted(monster_id_name_lst,
                                     cmp=lambda x, y: cmp(x['tid'], y['tid']))

        monster_model = memcache.get_cmem_val(
            cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)))
        monster_uid = monster_model['seq_id']

        return render_to_response(
            "data_edit/add_monster.html", {
                'user_id': user_id,
                'server_id': server_id,
                'monster_uid': monster_uid,
                'monster_id_name_lst': monster_id_name_lst
            }, RequestContext(request))
    elif request.method == 'POST':
        # 获取对应值
        user_id = str(request.POST.get('user_id'))
        monster_uid = int(request.POST.get('monster_uid'))
        server_id = int(request.POST.get('server_id'))
        monster_tid = int(request.POST.get("tid"))
        star_level = int(request.POST.get("star_level"))
        level = int(request.POST.get("level"))

        # 创建一个新宠物
        result = create_monster(user_id, monster_uid, server_id, monster_tid,
                                star_level, level)
        # 操作日志记录
        insert_action_create_monster(manager, server_id, user_id, monster_uid,
                                     monster_tid, star_level, level)

        # 创建完成返回宠物查询页面
        function_name = 'data_edit.monster_info_edit.{function}'.format(
            function=set_memcache.__name__)
        server_list, platform_list = daily_log._get_server_list(None, None)
        server_list.remove(server_list[0])

        cmem_url = server_define.CMEM_MAP[int(server_id)]
        monster_model = memcache.get_cmem_val(
            cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)))

        # 获取宠物相关最高值
        uid = monster_model['uid']
        monster_high_star_level = monster_model['monster_high_star_level']
        monster_kind = monster_model['monster_kind']
        monster_high_level = monster_model['monster_high_level']
        monster_high_quality = monster_model['monster_high_quality']

        all_monsters = monster_model['monsters']
        table_lst = []
        head_lst = [
            {
                'width': 50,
                'name': u'玩家ID'
            },
            {
                'width': 50,
                'name': u'宠物最高星级'
            },
            {
                'width': 50,
                'name': u'宠物最高等级'
            },
            {
                'width': 50,
                'name': u'宠物最高品质'
            },
            {
                'width': 50,
                'name': u'宠物种类个数'
            },
        ]
        row_lst = [
            uid, monster_high_star_level, monster_high_level,
            monster_high_quality,
            len(monster_kind)
        ]
        table_lst.append(row_lst)

        for _monster in all_monsters:
            _monster_config = game_config.get_monster_config(_monster['tid'])
            _monster['name'] = _monster_config['name']

        type_hidden = 'visible'
        # return HttpResponseRedirect("data_edit/monster_info_edit.html")
        return render_to_response(
            "data_edit/monster_info_edit.html", {
                "server_list": server_list,
                "user_id": user_id,
                'server_id': int(server_id),
                'row_lst': table_lst,
                'head_lst': head_lst,
                'monster_lst': all_monsters,
                'function_name': function_name,
                'type_hidden': type_hidden
            }, RequestContext(request))
Ejemplo n.º 35
0
def get_monster_lst(request):
    """
    数据后台 --- 宠物信息

    seq_id  <type 'int'>
    uid  <type 'str'>
    monster_high_star_level  <type 'int'>
    monster_kind <type 'list'>
    data_version  <type 'str'>
    monster_high_level  <type 'int'>
    monster_high_quality  <type 'int'>
    monsters <type 'str'>
    [
        evo_level 4 <type 'int'>
        star_level_exp 16 <type 'int'>
        skillsExp [0, 0] <type 'list'>
        level 54 <type 'int'>
        playerID 1000095298 <type 'str'>
        effort 2 <type 'int'>
        starLevel 3 <type 'int'>
        sex 0 <type 'int'>
        generation 1 <type 'int'>
        individual [1, 0, 1, 0, 0, 0] <type 'list'>
        evo_sun_stone 96 <type 'int'>
        skillsLevel [6, 10] <type 'list'>
        exp 11739 <type 'int'>
        personality 11 <type 'int'>
        tid 25 <type 'int'>
        uid 1 <type 'int'>
        star_level_rate 0.02083 <type 'float'>
        maxLevel 60 <type 'int'>
        createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'>
        evo_fail_count 0 <type 'int'>
    ]
    list中都是int
    HpIndividual = 0
    AttackIndividual = 1
    DefenceIndividual = 2
    SpcAttackIndividual = 3
    SpcDefenceIndividual = 4
    SpeedIndividual = 5
    """
    # 获取当前管理员
    manager = GameManager.get_by_request(request)

    function_name = 'data_edit.monster_info_edit.{function}'.format(
        function=set_memcache.__name__)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':
        user_uid = request.POST.get('user_uid')
        user_name = request.POST.get('user_name').encode('utf-8')
        user_openid = request.POST.get('user_openid')
        server_id = request.POST.get('server_id')
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        table_lst = []

        if len(user_uid):
            monster_model = memcache.get_cmem_val(
                cmem_url,
                model_define.MONSTER_MODEL.format(user_id=int(user_uid)))
        elif len(user_name):
            name = hashlib.md5(user_name).hexdigest().upper()
            key = model_define.PLAYER_NICK_NAME_MODEL.format(
                player_nick_md5=name)
            user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
            monster_model = memcache.get_cmem_val(
                cmem_url, model_define.MONSTER_MODEL.format(user_id=user_uid))
        elif len(user_openid):
            result = memcache.get_cmem_val(
                cmem_url,
                model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
            monster_model = memcache.get_cmem_val(
                cmem_url,
                model_define.MONSTER_MODEL.format(user_id=result['uid']))
        # 宠物相关最高值
        uid = monster_model['uid']
        monster_high_star_level = monster_model['monster_high_star_level']
        monster_kind = monster_model['monster_kind']
        monster_high_level = monster_model['monster_high_level']
        monster_high_quality = monster_model['monster_high_quality']
        all_monsters = monster_model['monsters']
        head_lst = [
            {
                'width': 50,
                'name': u'玩家ID'
            },
            {
                'width': 50,
                'name': u'宠物最高星级'
            },
            {
                'width': 50,
                'name': u'宠物最高等级'
            },
            {
                'width': 50,
                'name': u'宠物最高品质'
            },
            {
                'width': 50,
                'name': u'宠物种类个数'
            },
        ]
        row_lst = [
            uid, monster_high_star_level, monster_high_level,
            monster_high_quality,
            len(monster_kind)
        ]
        table_lst.append(row_lst)

        for _monster in all_monsters:
            _monster_config = game_config.get_monster_config(_monster['tid'])
            _monster['name'] = _monster_config['name']

        type_hidden = 'visible'
        return render_to_response(
            "data_edit/monster_info_edit.html", {
                "server_list": server_list,
                "user_uid": user_uid,
                'server_id': int(server_id),
                'row_lst': table_lst,
                'head_lst': head_lst,
                'monster_lst': all_monsters,
                'function_name': function_name,
                'type_hidden': type_hidden
            }, RequestContext(request))

    else:
        # row_list = []
        type_hidden = 'hidden'
        return render_to_response("data_edit/monster_info_edit.html", locals(),
                                  RequestContext(request))
Ejemplo n.º 36
0
def view_index(request):
    _gm = GameManager.get_by_request(request)
    if _gm:
        return render_to_response('auth/change_admin_password.html', {'id': _gm.uid})
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 37
0
def add_monster(request):
    """
        增加宠物数据
        {'generation': 1,  'star_level_rate': 0.02083, 'createTime': datetime.datetime(2015, 5, 31, 9, 12, 51, 761554)}

        evo_level 4 <type 'int'>
        star_level_exp 16 <type 'int'>
        skillsExp [0, 0] <type 'list'>
        level 54 <type 'int'>
        playerID 1000095298 <type 'str'>
        effort 2 <type 'int'>
        starLevel 3 <type 'int'> "4"
        sex 0 <type 'int'>
        generation 1 <type 'int'>
        individual [1, 0, 1, 0, 0, 0] <type 'list'>
        evo_sun_stone 96 <type 'int'>
        skillsLevel [6, 10] <type 'list'>
        exp 11739 <type 'int'>
        personality 11 <type 'int'>
        tid 25 <type 'int'>
        uid 1 <type 'int'>
        star_level_rate 0.02083 <type 'float'>
        maxLevel 60 <type 'int'>
        createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'>
        evo_fail_count 0 <type 'int'>
    """
    manager = GameManager.get_by_request(request)
    if request.method == "GET":
        user_id = request.GET.get("user_id")
        server_id = request.GET.get("server_id")
        cmem_url = server_define.CMEM_MAP[int(server_id)]

        # 获取宠物tid和名字对应列表
        monster_id_name = game_config.get_monster_config_with_id_name()
        monster_id_name_lst = []
        for (tid, name) in monster_id_name.items():
            content = dict()
            content["tid"] = tid
            content["name"] = name + "_" + str(tid)
            monster_id_name_lst.append(content)
        monster_id_name_lst = sorted(monster_id_name_lst, cmp=lambda x, y: cmp(x["tid"], y["tid"]))

        monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)))
        monster_uid = monster_model["seq_id"]

        return render_to_response(
            "data_edit/add_monster.html",
            {
                "user_id": user_id,
                "server_id": server_id,
                "monster_uid": monster_uid,
                "monster_id_name_lst": monster_id_name_lst,
            },
            RequestContext(request),
        )
    elif request.method == "POST":
        # 获取对应值
        user_id = str(request.POST.get("user_id"))
        monster_uid = int(request.POST.get("monster_uid"))
        server_id = int(request.POST.get("server_id"))
        monster_tid = int(request.POST.get("tid"))
        star_level = int(request.POST.get("star_level"))
        level = int(request.POST.get("level"))

        # 创建一个新宠物
        result = create_monster(user_id, monster_uid, server_id, monster_tid, star_level, level)
        # 操作日志记录
        insert_action_create_monster(manager, server_id, user_id, monster_uid, monster_tid, star_level, level)

        # 创建完成返回宠物查询页面
        function_name = "data_edit.monster_info_edit.{function}".format(function=set_memcache.__name__)
        server_list, platform_list = daily_log._get_server_list(None, None)
        server_list.remove(server_list[0])

        cmem_url = server_define.CMEM_MAP[int(server_id)]
        monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=str(user_id)))

        # 获取宠物相关最高值
        uid = monster_model["uid"]
        monster_high_star_level = monster_model["monster_high_star_level"]
        monster_kind = monster_model["monster_kind"]
        monster_high_level = monster_model["monster_high_level"]
        monster_high_quality = monster_model["monster_high_quality"]

        all_monsters = monster_model["monsters"]
        table_lst = []
        head_lst = [
            {"width": 50, "name": u"玩家ID"},
            {"width": 50, "name": u"宠物最高星级"},
            {"width": 50, "name": u"宠物最高等级"},
            {"width": 50, "name": u"宠物最高品质"},
            {"width": 50, "name": u"宠物种类个数"},
        ]
        row_lst = [uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind)]
        table_lst.append(row_lst)

        for _monster in all_monsters:
            _monster_config = game_config.get_monster_config(_monster["tid"])
            _monster["name"] = _monster_config["name"]

        type_hidden = "visible"
        # return HttpResponseRedirect("data_edit/monster_info_edit.html")
        return render_to_response(
            "data_edit/monster_info_edit.html",
            {
                "server_list": server_list,
                "user_id": user_id,
                "server_id": int(server_id),
                "row_lst": table_lst,
                "head_lst": head_lst,
                "monster_lst": all_monsters,
                "function_name": function_name,
                "type_hidden": type_hidden,
            },
            RequestContext(request),
        )
Ejemplo n.º 38
0
def set_player_data(request):
    # 获取管理员信息
    manager = GameManager.get_by_request(request)
    head_lst = [
        #{'width': 50, 'name': u'UID'},
        {'width': 50, 'name': u'名称'},
        {'width': 50, 'name': u'当前值'},
        {'width': 50, 'name': u'修改'},
        ]
    server_list_dat = get_server_list_dat()
    if request.method == 'POST':
        print request.POST,'post'
        user_id=request.POST.get('user_id')
        server_id=int(request.POST.get('server_id'))
        typ=request.POST.get('type')
        value=request.POST.get('value')
        #print 'value',value
        if value <> '':
            if typ <> 'str':
                if typ=='bool':
                    value=eval(typ)(eval(value))
                else:
                    value=eval(typ)(value)
                #print value
        key=request.POST.get('key')
        data=''
        if key=='newbie':
            # print 'newbie'
            # print int(value)
            # print get_newbie_phase_config(int(value))
            if get_newbie_phase_config(int(value))==None:
                data='新手引导ID应在1~5之间'
        elif key=='gold':
            pass
        elif key=='champion_index':
            if int(value) not in [1,2,3,4,0]:
                data='冠军宠物位置应该在0~4之间'
        elif key=='reward_cur_monster_star_level_id':
            if get_reward_monster_star_level_config(int(value))==None:
                data=u'宠物等级奖励序列应在1~18之间'
        elif key=='universal_fragment':
            pass
        elif key=='title':
            if get_the_title_config(int(value))==None:
                data='玩家爵位应在1~21之间'
        elif key=='consumption_point':
            pass
        elif key=='role_id':
            pass
        elif key=='reward_login_series_id':
            pass
        elif key=='reward_cur_monster_kind_id':
            if get_reward_monster_kind_config(int(value))==None:
                data='宠物种类奖励序列应在1~18之间'
        elif key=='has_first_recharge_lst':
            pass
        elif key=='is_stone_one_draw':
            if int(value) not in [0,1]:
                 data='首次钻石单抽状态取值应为0或1,0代表未抽过,1代表抽过'
        elif key=='is_ten_draw':
            if int(value) not in [0,1]:
                data='首次钻石十连抽状态取值应为0或1,0代表未抽过,1代表抽过'
        elif key=='champion_tid':
            cmem_url=server_define.CMEM_MAP[int(server_id)]
            source=memcache.get_cmem_val(cmem_url,model_define.MONSTER_MODEL.format(user_id=user_id))
            # print source['monsters']
            sign=0
            for i in source['monsters']:
                if int(value) == i['tid']:
                    sign=1
            # print sign
            if sign==0:
                data=u'输入的宠物id不属于玩家拥有的宠物之一,请正确输入,玩家现有宠物:'
                for i in source['monsters']:
                    a='(%s:%s)'% (i['tid'],get_monster_config(i['tid'])['name'])
                    data+=a
        elif key=='champion_power':
            pass
        elif key=='name':
            pass
        elif key=='level':
            if int(value)>120 or int(value)<1:
                data=u'玩家等级应在1~120级之间,请输入正确的值'
        elif key=='cur_stage':
            if get_stages_config(int(value))==None:
                data=u'关卡ID输入错误'
        elif key=='reward_cur_monster_quality_id':
            if get_reward_monster_quality_config(int(value))==None:
                data=u'当前宠物品质奖励序列应在1~3之间'
        elif key=='reward_cur_team_combat_power_id':
            if get_reward_team_power(int(value))==None:
                data=u'当前队伍战斗力奖励序列应在1~47之间'
        elif key=='reward_friend_num_id':
            if get_fried_num_config(int(value))==None:
                data=u'好友数量奖励序列应在1~6之间'
        elif key=='reward_cur_monster_level_id':
            if get_reward_monster_level_config(int(value))==None:
                data=u'宠物等级奖励序列应在1~10之间'

        if value <> ''and data=='':
            # print "i'work"
            cmem_url=server_define.CMEM_MAP[int(server_id)]
            if cmem_url:
                source=memcache.get_cmem_val(cmem_url,model_define.PLAYER_MODEL.format(user_id=user_id))
                if eval(typ)==type(value) or (typ=='str' and type(value)==unicode) :
                    #print source,key,value,user_id,type(user_id)
                    old_value = source[key]
                    source[key]=value
                    memcache.put_cmem_val(cmem_url,model_define.PLAYER_MODEL.format(user_id=user_id),source)
                    # 操作日志记录
                    insert_action_edit_player(manager, str(server_id), str(user_id), key, old_value, value)
        return HttpResponse(data)
Ejemplo n.º 39
0
def get_monster_lst(request):
    """
    数据后台 --- 宠物信息

    seq_id  <type 'int'>
    uid  <type 'str'>
    monster_high_star_level  <type 'int'>
    monster_kind <type 'list'>
    data_version  <type 'str'>
    monster_high_level  <type 'int'>
    monster_high_quality  <type 'int'>
    monsters <type 'str'>
    [
        evo_level 4 <type 'int'>
        star_level_exp 16 <type 'int'>
        skillsExp [0, 0] <type 'list'>
        level 54 <type 'int'>
        playerID 1000095298 <type 'str'>
        effort 2 <type 'int'>
        starLevel 3 <type 'int'>
        sex 0 <type 'int'>
        generation 1 <type 'int'>
        individual [1, 0, 1, 0, 0, 0] <type 'list'>
        evo_sun_stone 96 <type 'int'>
        skillsLevel [6, 10] <type 'list'>
        exp 11739 <type 'int'>
        personality 11 <type 'int'>
        tid 25 <type 'int'>
        uid 1 <type 'int'>
        star_level_rate 0.02083 <type 'float'>
        maxLevel 60 <type 'int'>
        createTime 2015-05-31 09:12:51.761554 <type 'datetime.datetime'>
        evo_fail_count 0 <type 'int'>
    ]
    list中都是int
    HpIndividual = 0
    AttackIndividual = 1
    DefenceIndividual = 2
    SpcAttackIndividual = 3
    SpcDefenceIndividual = 4
    SpeedIndividual = 5
    """
    # 获取当前管理员
    manager = GameManager.get_by_request(request)

    function_name = "data_edit.monster_info_edit.{function}".format(function=set_memcache.__name__)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == "POST":
        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name").encode("utf-8")
        user_openid = request.POST.get("user_openid")
        server_id = request.POST.get("server_id")
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        table_lst = []

        if len(user_uid):
            monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=int(user_uid)))
        elif len(user_name):
            name = hashlib.md5(user_name).hexdigest().upper()
            key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
            user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
            monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=user_uid))
        elif len(user_openid):
            result = memcache.get_cmem_val(cmem_url, model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
            monster_model = memcache.get_cmem_val(cmem_url, model_define.MONSTER_MODEL.format(user_id=result["uid"]))
        # 宠物相关最高值
        uid = monster_model["uid"]
        monster_high_star_level = monster_model["monster_high_star_level"]
        monster_kind = monster_model["monster_kind"]
        monster_high_level = monster_model["monster_high_level"]
        monster_high_quality = monster_model["monster_high_quality"]
        all_monsters = monster_model["monsters"]
        head_lst = [
            {"width": 50, "name": u"玩家ID"},
            {"width": 50, "name": u"宠物最高星级"},
            {"width": 50, "name": u"宠物最高等级"},
            {"width": 50, "name": u"宠物最高品质"},
            {"width": 50, "name": u"宠物种类个数"},
        ]
        row_lst = [uid, monster_high_star_level, monster_high_level, monster_high_quality, len(monster_kind)]
        table_lst.append(row_lst)

        for _monster in all_monsters:
            _monster_config = game_config.get_monster_config(_monster["tid"])
            _monster["name"] = _monster_config["name"]

        type_hidden = "visible"
        return render_to_response(
            "data_edit/monster_info_edit.html",
            {
                "server_list": server_list,
                "user_uid": user_uid,
                "server_id": int(server_id),
                "row_lst": table_lst,
                "head_lst": head_lst,
                "monster_lst": all_monsters,
                "function_name": function_name,
                "type_hidden": type_hidden,
            },
            RequestContext(request),
        )

    else:
        # row_list = []
        type_hidden = "hidden"
        return render_to_response("data_edit/monster_info_edit.html", locals(), RequestContext(request))
Ejemplo n.º 40
0
def select_account(request):
    """
        超级管理员授权管理
    """
    manager = GameManager.get_by_request(request)
    btn_lst = manager.check_admin_permission()
    if btn_lst:

        head_lst = [
            {
                'width': 20,
                'name': u'ID'
            },
            {
                'width': 50,
                'name': u'帐号'
            },
            {
                'width': 50,
                'name': u'名字'
            },
            {
                'width': 50,
                'name': u'权限'
            },
            {
                'width': 50,
                'name': u'最后登录IP'
            },
            {
                'width': 50,
                'name': u'最后登录时间'
            },
            {
                'width': 50,
                'name': u'描述'
            },
            {
                'width': 50,
                'name': u'操作'
            },
        ]

        if request.method == 'POST':
            return render_to_response(
                'auth/super_manage.html', {
                    'account': manager.account,
                    'btn_lst': btn_lst,
                    'head_lst': head_lst
                }, RequestContext(request))
        else:
            row_lst = administrators_information.get_table()
            return render_to_response(
                'auth/super_manage.html', {
                    'account': manager.account,
                    'btn_lst': btn_lst,
                    'head_lst': head_lst,
                    'row_lst': row_lst
                }, RequestContext(request))
    else:
        return HttpResponseRedirect('login/')
Ejemplo n.º 41
0
def index(request, equip_info_edit):
    """
        ①
        玩家装备数据
        此函数功能:1.显示最新数据 2.修改装备 3.删除装备 4.添加装备
    """
    # 获取当前管理员
    # 1.公用代码部分 即每次修改 删除 添加 数据后 显示最新数据
    manager = GameManager.get_by_request(request)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':

        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        user_openid = request.POST.get("user_openid")
        server_id = int(request.POST.get("server_id"))

        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        if cmem_url:
            print 'cmem_url', cmem_url
            try:
                source = {}
                if len(user_uid):
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_name):
                    name = hashlib.md5(user_name.encode('utf-8')).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_openid):
                    result = memcache.get_cmem_val(cmem_url,model_define.ACCOUNT_MAPPING_MODEL.format(open_id=user_openid))
                    user_uid = result['uid']
                    source = memcache.get_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                if source:
                    """以上是公用部分,以下是修改 删除 添加"""
                    # 2.修改装备
                    try:
                        old_edit_data = eval(request.POST.get("old_edit_data"))
                        old_edit_data.pop('name')                                       # 得到编辑的源数据
                        will_edit_tid = request.POST.get("will_edit_tid")               # 要改成装备tid
                        will_edit_tid_level = request.POST.get("will_edit_tid_level")   # 要改的装备的等级
                        result = edit_function(cmem_url, source, old_edit_data, int(will_edit_tid), int(will_edit_tid_level))
                        if result:
                            # 操作日志记录
                            insert_action_change_equip(manager, str(server_id), str(source['uid']), old_edit_data['uid'], old_edit_data['tid'], will_edit_tid, old_edit_data['level'], will_edit_tid_level)
                    except:
                        # 不是编辑 或 数据不对 跳过
                        pass

                    # 3.删除装备 删除比较简单不单写函数
                    try:
                        delete_data = eval(request.POST.get('delete_data'))
                        delete_data.pop('name')
                        if delete_data:
                            # 操作日志记录
                            insert_action_delete_equip(manager, str(server_id), str(user_uid), delete_data['uid'], delete_data['tid'], delete_data['level'])

                            source['equips'].remove(delete_data)
                            result = memcache.put_cmem_val(cmem_url, model_define.EQUIP_MODEL.format(user_id=int(user_uid)), source)
                    except:
                        # 不是删除 或 数据不对 跳过
                        pass

                    # 4.添加装备 添加比较简单不单写函数
                    try:
                        add_data = eval(request.POST.get('add_data'))
                        if add_data:
                            will_edit_tid = request.POST.get("will_edit_tid")
                            will_edit_tid_level = request.POST.get("will_edit_tid_level")
                            if will_edit_tid and will_edit_tid_level:
                                equip_config = game_config.get_equipment_config(int(will_edit_tid))
                                source['equips'].append({
                                    'uid': int(add_data),
                                    'tid': int(will_edit_tid),
                                    'level': int(will_edit_tid_level),
                                    'type': int(equip_config['type'])
                                    })
                                # 下个装备序列计数加1
                                source['seq_id'] = int(add_data) + 1
                                result = memcache.put_cmem_val(cmem_url,model_define.EQUIP_MODEL.format(user_id=int(user_uid)), source)
                                # 操作日志记录
                                insert_action_add_equip(manager, str(server_id), str(user_uid), add_data, will_edit_tid, will_edit_tid_level)
                                print "Finish"
                    except:
                        # 不是添加 或 数据不对 跳过
                        pass

                """以下是公用部分,以上是修改 删除 添加"""
                if source:
                    row_list = source['equips']
                    for each_value in row_list:
                        equip_config = game_config.get_item_config(each_value['tid'])
                        each_value['name'] = equip_config['name']

                return render_to_response(equip_info_edit, locals(), RequestContext(request))
            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(), RequestContext(request))
            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(), RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        row_dict = {}
        return render_to_response(equip_info_edit, locals(), RequestContext(request))
Ejemplo n.º 42
0
def index(request, equip_info_edit):
    """
        ①
        玩家装备数据
        此函数功能:1.显示最新数据 2.修改装备 3.删除装备 4.添加装备
    """
    # 获取当前管理员
    # 1.公用代码部分 即每次修改 删除 添加 数据后 显示最新数据
    manager = GameManager.get_by_request(request)
    server_list, platform_list = daily_log._get_server_list(None, None)
    server_list.remove(server_list[0])
    if request.method == 'POST':

        user_uid = request.POST.get("user_uid")
        user_name = request.POST.get("user_name")
        user_openid = request.POST.get("user_openid")
        server_id = int(request.POST.get("server_id"))

        type_hidden = 'visible'
        cmem_url = server_define.CMEM_MAP[int(server_id)]
        if cmem_url:
            print 'cmem_url', cmem_url
            try:
                source = {}
                if len(user_uid):
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_name):
                    name = hashlib.md5(
                        user_name.encode('utf-8')).hexdigest().upper()
                    key = model_define.PLAYER_NICK_NAME_MODEL.format(
                        player_nick_md5=name)
                    user_uid = memcache.get_cmem_val_no_pick(cmem_url, key)
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                elif len(user_openid):
                    result = memcache.get_cmem_val(
                        cmem_url,
                        model_define.ACCOUNT_MAPPING_MODEL.format(
                            open_id=user_openid))
                    user_uid = result['uid']
                    source = memcache.get_cmem_val(
                        cmem_url,
                        model_define.EQUIP_MODEL.format(user_id=user_uid))
                    # print source
                if source:
                    """以上是公用部分,以下是修改 删除 添加"""
                    # 2.修改装备
                    try:
                        old_edit_data = eval(request.POST.get("old_edit_data"))
                        old_edit_data.pop('name')  # 得到编辑的源数据
                        will_edit_tid = request.POST.get(
                            "will_edit_tid")  # 要改成装备tid
                        will_edit_tid_level = request.POST.get(
                            "will_edit_tid_level")  # 要改的装备的等级
                        result = edit_function(cmem_url, source, old_edit_data,
                                               int(will_edit_tid),
                                               int(will_edit_tid_level))
                        if result:
                            # 操作日志记录
                            insert_action_change_equip(manager, str(server_id),
                                                       str(source['uid']),
                                                       old_edit_data['uid'],
                                                       old_edit_data['tid'],
                                                       will_edit_tid,
                                                       old_edit_data['level'],
                                                       will_edit_tid_level)
                    except:
                        # 不是编辑 或 数据不对 跳过
                        pass

                    # 3.删除装备 删除比较简单不单写函数
                    try:
                        delete_data = eval(request.POST.get('delete_data'))
                        delete_data.pop('name')
                        if delete_data:
                            # 操作日志记录
                            insert_action_delete_equip(manager, str(server_id),
                                                       str(user_uid),
                                                       delete_data['uid'],
                                                       delete_data['tid'],
                                                       delete_data['level'])

                            source['equips'].remove(delete_data)
                            result = memcache.put_cmem_val(
                                cmem_url,
                                model_define.EQUIP_MODEL.format(
                                    user_id=int(user_uid)), source)
                    except:
                        # 不是删除 或 数据不对 跳过
                        pass

                    # 4.添加装备 添加比较简单不单写函数
                    try:
                        add_data = eval(request.POST.get('add_data'))
                        if add_data:
                            will_edit_tid = request.POST.get("will_edit_tid")
                            will_edit_tid_level = request.POST.get(
                                "will_edit_tid_level")
                            if will_edit_tid and will_edit_tid_level:
                                equip_config = game_config.get_equipment_config(
                                    int(will_edit_tid))
                                source['equips'].append({
                                    'uid':
                                    int(add_data),
                                    'tid':
                                    int(will_edit_tid),
                                    'level':
                                    int(will_edit_tid_level),
                                    'type':
                                    int(equip_config['type'])
                                })
                                # 下个装备序列计数加1
                                source['seq_id'] = int(add_data) + 1
                                result = memcache.put_cmem_val(
                                    cmem_url,
                                    model_define.EQUIP_MODEL.format(
                                        user_id=int(user_uid)), source)
                                # 操作日志记录
                                insert_action_add_equip(
                                    manager, str(server_id), str(user_uid),
                                    add_data, will_edit_tid,
                                    will_edit_tid_level)
                                print "Finish"
                    except:
                        # 不是添加 或 数据不对 跳过
                        pass
                """以下是公用部分,以上是修改 删除 添加"""
                if source:
                    row_list = source['equips']
                    for each_value in row_list:
                        equip_config = game_config.get_item_config(
                            each_value['tid'])
                        each_value['name'] = equip_config['name']

                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))
            except UnboundLocalError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))
            except TypeError:
                type_hidden = 'hidden'
                return render_to_response(equip_info_edit, locals(),
                                          RequestContext(request))

    else:
        row_list = []
        type_hidden = 'hidden'
        row_dict = {}
        return render_to_response(equip_info_edit, locals(),
                                  RequestContext(request))