示例#1
0
文件: views.py 项目: qoelet/buzzfire
def add(request):
    oauth_status = check_auth(request)
    if oauth_status:
        conn = get_redis_conn()
        comment_dao = CommentDao(conn)
        if request.method  == 'POST':
            owner_id = request.POST["owner_id"]
            bookmark_id = request.POST["bookmark_id"]
            text = request.POST["text"]
            comment = Comment(owner_id, bookmark_id, text)
            id = comment_dao.save(comment)
            if id:
                comment = comment_dao.get_comment(id)
                result  = json.dumps(comment, default=Comment.json_encode)
                return HttpResponse(result)
            else:
                result = '{"status":"error"}'
                return HttpResponse(result)
        else:
            return HttpResponse()
    else:
        return HttpResponseRedirect(settings.BUZZFIRE_LOGIN_URL)
示例#2
0
文件: tests.py 项目: qoelet/buzzfire
 def test_comment_dao(self):
     conn = redis.Redis("localhost")
     comment = Comment("1", "1", "hello")
     commentDao = CommentDao(conn)
     commentDao.save(comment)
     commentDao.get_comment("1")