예제 #1
0
파일: book.py 프로젝트: iazxq/mywebresource
def book_chapter_del(request):
    '删除'
    id = func.get_int_param_from_get(request,'id')
    book_chapter_facade = BookChapterFacade()
    book_chapter_facade.remove(id)
    return_url = func.get_referer(request,'book_chapter_list')
    return HttpResponseRedirect(return_url)
예제 #2
0
파일: book.py 프로젝트: iazxq/mywebresource
def book_chapter_list(request):
    '章节管理'
    book_id = func.get_int_param_from_get(request,'book_id')
    book_chapter_facade = BookChapterFacade()
    book_facade = BookFacade();
    book = book_facade.get_data(book_id)
    book_chapters = book_chapter_facade.search(book_id)
    book_chapter_list = book_chapters['list']
    total_count = book_chapters['total_count']
    output = {
        'book':book,
        'book_chapter_list':book_chapter_list,
        'book_id':book_id,
    }
    return render_to_response('admin/book_chapter_list.html',output)
예제 #3
0
파일: book.py 프로젝트: iazxq/mywebresource
def book_chapter_edit(request):
    book_facade = BookFacade()
    book_chapter_facade = BookChapterFacade()
    id = func.get_int_param_from_get(request,'id')
    book_id = func.get_int_param_from_get(request,'book_id')
    book = book_facade.get_data(book_id)
    output = {'book_id':book_id,'book':book,}

    if request.method=="POST":
        book_chapter = BookChaper()
        book_chapter.book_id = func.get_int_param_from_post(request,'book_id')
        book_chapter.title = request.POST.get('title','')
        book_chapter.content = request.POST.get('content','')
        if id:#修改
            book_chapter.id = id
            messages = book_chapter.validate()
            if not messages:
                book_chapter_facade.update(book_chapter)
                return_url = 'book_chapter_list?book_id=%s'%book_chapter.book_id
                return HttpResponseRedirect(return_url)
            else:
                output['messages'] = messages
                return render_to_response('admin/book_chapter_edit.html',output)
        else:#插入
            book_chapter.id = func.create_new_id()
            messages = book_chapter.validate()
            if not messages:
                book_chapter_facade.insert(book_chapter)
                return_url = 'book_chapter_list?book_id=%s'%book_chapter.book_id
                return HttpResponseRedirect(return_url)
            else:
                output['messages'] = messages
                return render_to_response('admin/book_chapter_edit.html',output)

    #get 页面
    if id>0:
        book_chapter = book_chapter_facade.get_data(id)
        output['book_chapter'] = book_chapter

    return render_to_response('admin/book_chapter_edit.html',output)