Пример #1
0
def config_level_add(request,template="admin/config/level/add.tpl"):
    if request.method == "GET":
        return render_response(template)
    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 = ConfigLevel.objects.create(level=level,update_need_xp=update_need_xp,
                                                  max_ep=max_ep,max_sp=max_sp,base_slot_count=base_slot_count)
                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_add'}).close();</script>")
Пример #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>")