Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def config_level_edit(request,config_level_id=0,template="admin/config/level/edit.tpl"):
    config_level = ConfigLevel.get_by_id(config_level_id)
    if request.method == "GET":
        return render_response(template,config_level=config_level)
    elif request.method == "POST":
        form = ConfigLevelForm(request.POST)
        if form.is_valid():
            level = form.cleaned_data['level']
            update_need_xp = form.cleaned_data['update_need_xp']
            max_ep = form.cleaned_data['max_ep']
            max_sp = form.cleaned_data['max_sp']
            base_slot_count = form.cleaned_data['base_slot_count']
            try:
                config_level.level = level
                config_level.update_need_xp = update_need_xp
                config_level.base_slot_count = base_slot_count
                config_level.max_ep = max_ep
                config_level.max_sp = max_sp
                config_level.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:'config_level_edit'}).close();</script>")