コード例 #1
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>")
コード例 #2
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("网络错误,请稍后再试...")