Beispiel #1
0
def comments(req, action):
    settings = setting
    if req.method == 'GET':
        if action == 'new':
            comment_info = {}
            return render_to_response("backend/comments.html", locals())
        elif action == 'edit':
            id = req.GET.get('id')
            if not id:
                id = 0
            comment_info = controller.get_comment_info(id)
            return render_to_response("backend/comments.html", locals())
        elif action == 'list':
            page = req.GET.get('page')
            if not page:
                page = 1
            if int(page) > 0:
                comment_list = controller.get_comment_list(req, page)
            else:
                comment_list = []
            return render_to_response("backend/commentslist.html", locals())
    elif req.method == 'POST':
        data = req.POST
        if action == 'save':
            r = controller.save_comment(data)
            if r:
                return HttpResponseRedirect('/backend/comments/list/')
            else:
                msg = '保存失败'
            return render_to_response("backend/msg.html", locals())
            # return HttpResponse(json.dumps(data),content_type="application/json")
        elif action == 'del':
            id = data.get('id')
            if controller.del_comment(id):
                result = {'errorCode': 0, 'msg': '删除成功'}
            else:
                result = {'errorCode': -1, 'msg': '删除失败'}
            return HttpResponse(json.dumps(result),
                                content_type="application/json")
Beispiel #2
0
def comments(req, action):
    settings = setting
    if req.method=='GET':
        if action=='new':
            comment_info = {}
            return render_to_response("backend/comments.html", locals())
        elif action=='edit':
            id = req.GET.get('id')
            if not id:
                id = 0
            comment_info = controller.get_comment_info(id)
            return render_to_response("backend/comments.html", locals())
        elif action=='list':
            page = req.GET.get('page')
            if not page:
                page = 1
            if int(page)>0:
                comment_list = controller.get_comment_list(req, page)
            else:
                comment_list = []
            return render_to_response("backend/commentslist.html", locals())
    elif req.method=='POST':
        data = req.POST
        if action=='save':
            r = controller.save_comment(data)
            if r:
                return HttpResponseRedirect('/backend/comments/list/')
            else:
                msg = '保存失败'
            return render_to_response("backend/msg.html", locals())
            # return HttpResponse(json.dumps(data),content_type="application/json")
        elif action=='del':
            id = data.get('id')
            if controller.del_comment(id):
                result = {'errorCode':0, 'msg':'删除成功'}
            else:
                result = {'errorCode':-1, 'msg':'删除失败'}
            return HttpResponse(json.dumps(result),content_type="application/json")
Beispiel #3
0
def index(req):
    settings = setting
    post_list = controller.get_post_list(req, 1, 5)
    comment_list = controller.get_comment_list(req, 1, 5)
    return render_to_response("backend/index.html", locals())
Beispiel #4
0
def index(req):
    settings = setting
    post_list = controller.get_post_list(req, 1, 5)
    comment_list = controller.get_comment_list(req, 1, 5)
    return render_to_response("backend/index.html", locals())