예제 #1
0
def scenario_list(request, cur_page=1, template="admin/mission/scenario/list.tpl"):  
    count = Scenario.get_count()
    if count != 0:
        page = int(cur_page)
        scenario_list = Scenario.get_list(page)
        p = Paginator(page, count, page_size=config.default_page_size)
        if scenario_list:
            return render_response(template, request=request, scenario_list=scenario_list, p=p)
    return render_response(template, request=None, scenario_list=None, p=None)
예제 #2
0
파일: views_card.py 프로젝트: codinl/mydj
def weapon_list(request,cur_page=1,template="admin/card/weapon/list.tpl"):  
    count = Card.get_card_count("Weapon")
    if count != 0:
        page = int(cur_page)
        weapon_list = Card.get_card_list("Weapon",page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if weapon_list:
            return render_response(template,request=request,weapon_list=weapon_list,p=p)
    return render_response(template,request=None,weapon_list=None,p=None)
예제 #3
0
파일: views_mall.py 프로젝트: codinl/mydj
def order_list(request, cur_page=1, template="admin/mall/order/list.tpl"):
    count = Order.get_count()
    if count != 0:
        page = int(cur_page)
        order_list = Order.get_list(page, config.default_page_size)
        p = Paginator(page, count, page_size=config.default_page_size)
        if recharge_list:
            return render_response(template, request=request, order_list=order_list, p=p)
    return render_response(template, request=None, recharge_list=None, p=None)
예제 #4
0
파일: views_mall.py 프로젝트: codinl/mydj
def good_list(request, cur_page=1, template="admin/mall/good/list.tpl"):
    count = Good.get_count()
    if count != 0:
        page = int(cur_page)
        good_list = Good.get_list(page, config.default_page_size)
        p = Paginator(page, count, page_size=config.default_page_size)
        if good_list:
            return render_response(template, request=request, good_list=good_list, p=p)
    return render_response(template, request=None, good_list=None, p=None)
예제 #5
0
파일: views_card.py 프로젝트: codinl/mydj
def shield_list(request,cur_page=1,template="admin/card/shield/list.tpl"):  
    count = Card.get_card_count("Shield")
    if count != 0:
        page = int(cur_page)
        shield_list = Card.get_card_list("Shield",page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if shield_list:
            return render_response(template,request=request,shield_list=shield_list,p=p)
    return render_response(template,request=None,shield_list=None,p=None)
예제 #6
0
파일: views_admin.py 프로젝트: codinl/mydj
def node_list(request,cur_page=1,template="admin/node/list.tpl"):
    count = Node.get_count()
    if count != 0:
        page = int(cur_page)
        node_list = Node.get_list(page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if node_list:
            return render_response(template,request=request,node_list=node_list,p=p)
    return render_response(template,request=None,node_list=None,p=None)
예제 #7
0
파일: views_card.py 프로젝트: codinl/mydj
def general_list(request,cur_page=1,template="admin/card/general/list.tpl"):  
    count = Card.get_card_count("General")
    if count != 0:
        page = int(cur_page)
        general_list = Card.get_card_list("General",page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if general_list:
            return render_response(template,request=request,general_list=general_list,p=p)
    return render_response(template,request=None,general_list=None,p=None)
예제 #8
0
파일: views_card.py 프로젝트: codinl/mydj
def treasure_part_list(request,cur_page=1,template="admin/card/treasure_part/list.tpl"):  
    count = Card.get_card_count("TreasurePart")
    if count != 0:
        page = int(cur_page)
        treasure_part_list = Card.get_card_list("TreasurePart",page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if treasure_part_list:
            return render_response(template,request=request,treasure_part_list=treasure_part_list,p=p)
    return render_response(template,request=None,treasure_part_list=None,p=None)
예제 #9
0
파일: views_card.py 프로젝트: codinl/mydj
def secret_book_part_list(request,cur_page=1,template="admin/card/secret_book_part/list.tpl"):  
    count = Card.get_card_count("SecretBookPart")
    if count != 0:
        page = int(cur_page)
        secret_book_part_list = Card.get_card_list("SecretBookPart",page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if secret_book_part_list:
            return render_response(template,request=request,secret_book_part_list=secret_book_part_list,p=p)
    return render_response(template,request=None,secret_book_part_list=None,p=None)
예제 #10
0
파일: views_config.py 프로젝트: codinl/mydj
def config_level_list(request,cur_page=1,template="admin/config/level/list.tpl"):  
    count = ConfigLevel.get_count()
    if count != 0:
        page = int(cur_page)
        config_level_list = ConfigLevel.get_list(page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if config_level_list:
            return render_response(template,request=request,config_level_list=config_level_list,p=p)
    return render_response(template,request=None,config_level_list=None,p=None)
예제 #11
0
파일: views_market.py 프로젝트: codinl/mydj
def market_list(request,cur_page=1,template="admin/market/list.tpl"):  
    count = Market.get_count()
    if count != 0:
        page = int(cur_page)
        market_list = Market.get_list(page,config.default_page_size)
        p = Paginator(page,count,page_size=config.default_page_size)
        if market_list:
            return render_response(template,request=request,market_list=market_list,p=p)
    return render_response(template,request=None,market_list=None,p=None)
예제 #12
0
파일: views_player.py 프로젝트: codinl/mydj
def player_search(request,template="admin/player/search.tpl"): 
    if request.method == "POST":
        player_name = request.POST.get('player_name')
        if player_name:
            player_list = Player.search_by_name(player_name)
            if player_list:
                count = len(player_list)
                p = Paginator(1,count,page_size=config.default_page_size)
                if player_list:
                    return render_response("admin/player/list.tpl",request=request,player_list=player_list,p=p)
    return render_response(template,request=None,player_list=None,p=None)
예제 #13
0
파일: views_skill.py 프로젝트: codinl/mydj
def skill_list(request, cur_page=1, template="admin/skill/list.tpl"):  
    skill_all_list = Skill.get_all()
    if skill_all_list:
        count = len(skill_all_list)
        if count > 0:
            page = int(cur_page)
            page_start = (page-1)*config.default_page_size
            page_end = page*config.default_page_size
            if page_end > (count-1):
                page_end = (count-1)
            skill_list = skill_all_list[page_start:page_end]
            p = Paginator(page, count, page_size=config.default_page_size)
            return render_response(template, request=request, skill_list=skill_list, p=p)
    return render_response(template, request=None, skill_list=None, p=None)
예제 #14
0
파일: views_mall.py 프로젝트: codinl/mydj
def recharge_add(request, template="admin/mall/recharge/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        form = RechargeForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]
            #             type_id = form.cleaned_data['type_id']
            money = form.cleaned_data["money"]
            rm = form.cleaned_data["rm"]
            discount = form.cleaned_data["discount"]
            description = form.cleaned_data["description"]
            #             status = form.cleaned_data['status']
            try:
                recharge = Recharge.objects.create(
                    name=name, money=money, rm=rm, description=description, discount=discount
                )
                recharge.save()
            except Exception, e:
                if config.debug:
                    print e
            else:
                return HttpResponse(
                    "<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'recharge_add'}).close();</script>"
                )
예제 #15
0
파일: views_card.py 프로젝트: codinl/mydj
def shield_edit(request,shield_id=0,template="admin/card/shield/edit.tpl"):
    shield = Card.get_card("Shield",shield_id)
    if request.method == "GET":
        return render_response(template,shield=shield)
    elif request.method == "POST":
        form = ShieldForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            description = form.cleaned_data['description']
            rebirth_max = form.cleaned_data['rebirth_max']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            defence = form.cleaned_data['defence']
            try:
                edit_card = False
                if (rarity != shield.rarity) or (name != shield.name):
                    edit_card = True
                shield.name = name
                shield.rarity = rarity
                shield.description = description
                shield.rebirth_max = rebirth_max
                shield.is_unlock = is_unlock
                if image:
                    shield.image = image
                shield.defence = defence
                shield.save()
                if edit_card:
                    _edit_card(shield,"Shield")
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'shield_edit'}).close();</script>")
예제 #16
0
파일: views_card.py 프로젝트: codinl/mydj
def weapon_edit(request,weapon_id=0,template="admin/card/weapon/edit.tpl"):
    weapon = Card.get_card("Weapon",weapon_id)
    if request.method == "GET":
        return render_response(template,weapon=weapon)
    elif request.method == "POST":
        form = WeaponForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            description = form.cleaned_data['description']
            rebirth_max = form.cleaned_data['rebirth_max']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            attack = form.cleaned_data['attack']
            try:
                edit_card = False
                if (rarity != weapon.rarity) or (name != weapon.name):
                    edit_card = True
                weapon.name = name
                weapon.rarity = rarity
                weapon.description = description
                weapon.attack = attack
                weapon.rebirth_max = rebirth_max
                weapon.is_unlock = is_unlock
                if image:
                    weapon.image = image
                weapon.save()
                if edit_card:
                    _edit_card(weapon,"Weapon")
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'weapon_edit'}).close();</script>")
예제 #17
0
파일: views_mall.py 프로젝트: codinl/mydj
def recharge_edit(request, recharge_id=0, template="admin/mall/recharge/edit.tpl"):
    recharge = Recharge.get_by_id(recharge_id)
    if request.method == "GET":
        return render_response(template, recharge=recharge)
    elif request.method == "POST":
        form = RechargeForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]
            #             type_id = form.cleaned_data['type_id']
            money = form.cleaned_data["money"]
            rm = form.cleaned_data["rm"]
            discount = form.cleaned_data["discount"]
            description = form.cleaned_data["description"]
            #             status = form.cleaned_data['status']
            try:
                recharge.name = name
                #                 recharge.type_id = type_id
                recharge.money = money
                recharge.rm = rm
                recharge.discount = discount
                recharge.description = description
                #                 recharge.status = status
                recharge.save()
            except Exception, e:
                if config.debug:
                    print e
            else:
                return HttpResponse(
                    "<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'recharge_edit'}).close();</script>"
                )
예제 #18
0
파일: views_player.py 프로젝트: codinl/mydj
def player_edit(request,player_id=0,template="admin/player/edit.tpl"):
    player = Player.get_by_id(player_id)
    if request.method == "GET":
        return render_response(template,player=player)
    elif request.method == "POST":
        form = PlayerForm(request.POST)
        if form.is_valid():
            level = form.cleaned_data['level']
            ep = form.cleaned_data['ep']
            sp = form.cleaned_data['sp']
            vm = form.cleaned_data['vm']
            grm = form.cleaned_data['grm']
            brm = form.cleaned_data['brm']
            try:
                player.level = level
                player.ep = ep
                player.sp = sp
                player.vm = vm
                player.grm = grm
                player.brm = brm
                player.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'player_edit'}).close();</script>")
예제 #19
0
파일: views_card.py 프로젝트: codinl/mydj
def secretbook_add(request,template="admin/card/secretbook/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        form = SecretBookForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            description = form.cleaned_data['description']
#             add_value_percent = form.cleaned_data['add_value_percent']
            attack_add_percent = form.cleaned_data['attack_add_percent']
            defence_add_percent = form.cleaned_data['defence_add_percent']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            try:
                secretbook = SecretBook.objects.create(name=name,rarity=rarity,description=description,
                                                       attack_add_percent=attack_add_percent,defence_add_percent=defence_add_percent,
                                                       image=image,is_unlock=is_unlock)
                _add_card(secretbook,"密卷","SecretBook")
                secretbook.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'secretbook_add'}).close();</script>")
예제 #20
0
파일: views_card.py 프로젝트: codinl/mydj
def secretbook_edit(request,secretbook_id=0,template="admin/card/secretbook/edit.tpl"):
    secretbook = Card.get_card("SecretBook",secretbook_id)
    if request.method == "GET":
        return render_response(template,secretbook=secretbook)
    elif request.method == "POST":
        form = SecretBookForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            description = form.cleaned_data['description']
#             add_value_percent = form.cleaned_data['add_value_percent']
            attack_add_percent = form.cleaned_data['attack_add_percent']
            defence_add_percent = form.cleaned_data['defence_add_percent']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            try:
                edit_card = False
                if (rarity != secretbook.rarity) or (name != secretbook.name):
                    edit_card = True
                secretbook.name = name
                secretbook.rarity = rarity
                secretbook.description = description
                secretbook.attack_add_percent = attack_add_percent
                secretbook.defence_add_percent = defence_add_percent
                secretbook.is_unlock = is_unlock
                if image:
                    secretbook.image = image
                secretbook.save()
                if edit_card:
                    _edit_card(secretbook,"SecretBook")
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'secretbook_edit'}).close();</script>")
예제 #21
0
파일: views_card.py 프로젝트: codinl/mydj
def fall_cards_update(request,template="admin/card/update_fall_cards.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        try:
            raw_sql = "TRUNCATE TABLE card_card;"
            Card.objects.raw(raw_sql)
            card_types = [["General","武将"],
                          ["Weapon","武器"],
                          ["Shield","防具"],
                          ["Treasure","宝物"],
                          ["TreasurePart","碎片"],
                          ["SecretBook","密卷"],
                          ["SecretPart","残卷"]]
            for card_type in card_types:
                card_list = Card.get_card_all(card_type[0])
                if card_list:
                    for card in card_list:
                        c = Card.objects.create(r_card_id=card.id,type_name=card_type[1],
                                                card_type=card_type[0],
                                                rarity=card.rarity,
                                                card_name=card.name)
                        c.save()
        except Exception,e:
            if config.debug:
                print e
        else:
            return HttpResponse("1")
예제 #22
0
파일: views_card.py 프로젝트: codinl/mydj
def general_add(request,template="admin/card/general/add.tpl"):
    group_list = Group.get_all()
    if request.method == "GET":
        return render_response(template,group_list=group_list)
    elif request.method == "POST":
        form = GeneralForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            level = form.cleaned_data['level']
            group_id = form.cleaned_data['group_id']
            description = form.cleaned_data['description']
            attack = form.cleaned_data['attack']
            defence = form.cleaned_data['defence']
            rebirth_max = form.cleaned_data['rebirth_max']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            is_add_attack = form.cleaned_data['is_add_attack']
            is_for_init = form.cleaned_data['is_for_init']
            level_max = Card.get_level_max(rarity, 0);
            try:
                general = General.objects.create(name=name,rarity=rarity,level=level,
                                                 group_id=group_id,description=description,attack=attack,
                                                 defence=defence,rebirth_max=rebirth_max,is_unlock=is_unlock,
                                                 level_max=level_max,is_add_attack=is_add_attack,
                                                 is_for_init=is_for_init,image=image)
                general.save()
                _add_card(general,"武将","General")
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'general_add'}).close();</script>")
예제 #23
0
def mission_group_edit(request, mission_group_id=0, template="admin/mission/mission_group/edit.tpl"):
    mission_group = MissionGroup.get_by_id(mission_group_id)
    if request.method == "GET":
        scenario_list = Scenario.get_all()
        return render_response(template, mission_group=mission_group, scenario_list=scenario_list)
    elif request.method == "POST":
        form = MissionGroupForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            order = form.cleaned_data['order']
#             level = form.cleaned_data['level']
            is_unlock = form.cleaned_data['is_unlock']
            scenario_id = form.cleaned_data['scenario_id']
            is_scenario_last = form.cleaned_data['is_scenario_last']
            try:
                mission_group.name = name
                mission_group.order = order
                mission_group.is_unlock = is_unlock
#                 mission_group.level = level
                mission_group.scenario_id = scenario_id
                mission_group.is_scenario_last = is_scenario_last
                mission_group.save()
            except Exception, e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'mission_group_edit'}).close();</script>")
예제 #24
0
파일: views_card.py 프로젝트: codinl/mydj
def secret_book_part_edit(request,secret_book_part_id=0,template="admin/card/secret_book_part/edit.tpl"):
    secret_book_part = Card.get_card("SecretBookPart",secret_book_part_id)
    if request.method == "GET":
        t_card_list = Card.get_card_all("SecretBook")
        return render_response(template,t_card_list=t_card_list,
                               secret_book_part=secret_book_part)
    elif request.method == "POST":
        form = SecretBookPartForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            description = form.cleaned_data['description']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            rarity = form.cleaned_data['rarity']
            t_card_id = form.cleaned_data['t_card_id']
            try:
                secret_book_part.name = name
                secret_book_part.description = description
                secret_book_part.is_unlock = is_unlock
                if image:
                    secret_book_part.image = image
                secret_book_part.rarity = rarity
                secret_book_part.t_card_id = t_card_id
                secret_book_part.save()
                if secret_book_part:
                    _edit_card(secret_book_part,"SecretBookPart")
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'secret_book_part_edit'}).close();</script>")
예제 #25
0
파일: views_admin.py 프로젝트: codinl/mydj
def node_edit(request,node_id,template="admin/node/edit.tpl"):
    if request.method == "GET":
        if node_id:
            node_id = int(node_id)
            node = Node.get_by_id(node_id)
            level_1_list = Node.get_level(1)
            return render_response(template,node=node,level_1_list=level_1_list)
    elif request.method == "POST":
        form = NodeForm(request.POST)
        if form.is_valid():
            id = form.cleaned_data['id']
            url = form.cleaned_data['url']
            name = form.cleaned_data['name']
            level = form.cleaned_data['level']
            parent = form.cleaned_data['parent']
            is_show = bool(form.cleaned_data['is_show'])
            sort = form.cleaned_data['sort']
            descr = form.cleaned_data['descr']
            try:
#                node = Node.objects.get_or_create(id=id,url=url,name=name,level=level,parent_id=parent,is_show=is_show,sort=sort,descr=descr)
                node = Node.get_by_id(id)
                node.url = url
                node.name = name
                node.level = level
                node.parent_id = parent
                node.is_show = is_show
                node.sort = sort
                node.descr = descr
                node.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'node_edit'}).close();</script>")
예제 #26
0
파일: views_card.py 프로젝트: codinl/mydj
def treasure_add(request,template="admin/card/treasure/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        form = TreasureForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            rarity = form.cleaned_data['rarity']
            description = form.cleaned_data['description']
#             probability = form.cleaned_data['probability']
            block = form.cleaned_data['block']
            crit = form.cleaned_data['crit']
            is_unlock = form.cleaned_data['is_unlock']
            image = form.cleaned_data['image']
            try:
                treasure = Treasure.objects.create(name=name,rarity=rarity,description=description,
                                                   block = block,crit=crit,
                                                   image=image,is_unlock=is_unlock)
                _add_card(treasure,"宝物","Treasure")
                treasure.save()
            except Exception,e:
                if config.debug:
                    print e
            else:
                return HttpResponse("<script type='text/javascript'>window.top.right.location.reload();window.top.art.dialog({id:'treasure_add'}).close();</script>")
예제 #27
0
def system_message_list(request,cur_page=1,template="admin/system_message/list.tpl"):  
    count = SystemMessage.get_count()
    if count != 0:
        page = int(cur_page)
        system_message_list = SystemMessage.get_list(page)
        p = Paginator(page,count,page_size=config.default_page_size)
        if system_message_list:
            _system_message_list = []
            # 格式化时间
            for m in system_message_list:
                m.create_time = time_util.seconds_to_str(m.create_time)
                m.update_time = time_util.seconds_to_str(m.update_time)
                _system_message_list.append(m)
            return render_response(template,request=request,
                                   system_message_list=_system_message_list,
                                   p=p)
    return render_response(template,request=None,system_message_list=None,p=None)
예제 #28
0
파일: views_skill.py 프로젝트: codinl/mydj
def import_skill(request, template="admin/skill/import.tpl"):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            import_file  = request.FILES['import_file']
            skill_list = _init_skill_list(import_file)
            import_file.close()
            _do_import(skill_list)
        return HttpResponse("<script type='text/javascript'>alert('导入成功');</script>")
    return render_response(template)
예제 #29
0
파일: views_card.py 프로젝트: codinl/mydj
def battle_fall_cards_update(request,template="admin/card/update_fall_cards.tpl"):
    if request.method == "GET":
        return render_response(template)
    elif request.method == "POST":
        try:
            from base.obj import BattleFallCard
            BattleFallCard().init()
        except Exception,e:
            if config.debug:
                print e
        else:
            return HttpResponse("1")
예제 #30
0
파일: views_admin.py 프로젝트: codinl/mydj
def home(request,cur_menu_id=1,template="admin/main.tpl"):
    menu_list = Node.get_level(1)
    cur_menu_id = int(cur_menu_id)
    parent = Node.get_by_id(cur_menu_id)
    user_name = ""
    admin = request.admin   
    if admin:
        user_name = admin.name

    if parent:
        node_list = parent.get_children()
        return render_response(template,menu_list=menu_list,
                               node_list=node_list,cur_menu_id=cur_menu_id,
                               user_name = user_name)
    return HttpResponse("网络错误,请稍后再试...")