コード例 #1
0
ファイル: views.py プロジェクト: five3/zyw
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")
コード例 #2
0
ファイル: views.py プロジェクト: five3/uplus
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")
コード例 #3
0
ファイル: views.py プロジェクト: five3/zyw
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())
コード例 #4
0
ファイル: views.py プロジェクト: five3/uplus
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())