def add_comment(request): post_key = request.POST["post_key"].strip() post = db.get(post_key) author = get_user() nickname = request.POST["nickname"].strip() email = request.POST["email"].strip() link = request.POST["link"].strip() if not link: link = None content = request.POST["content"].strip() if not nickname or not email or not content: return HttpResponse(simplejson.dumps({"state": "err", "msg": u"请完整填写昵称、电子邮件和内容"})) if not re.match(r"^\w+((_-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$", email): return HttpResponse(simplejson.dumps({"state": "err", "msg": u"邮箱地址格式不正确"})) ip = request.META["REMOTE_ADDR"] if author: Comment.auth_add(post, content, ip, author_nickname=nickname, link=link) else: Comment.anonymous_add(post, content, ip, email, nickname, link=link) return HttpResponse(simplejson.dumps({"state": "ok", "msg": u"评论发表成功"}))
def comment_list(request): page = int(request.GET.get('page', 1)) if page < 1: page = 1 comment_list = Comment.all().order('-add_time').fetch(150) return render_to_response('admin/comment_list.html', { 'comment_list': comment_list, }, RequestContext(request))