Пример #1
0
    def POST(self):
        inp = web.input(close_after=False, item_host=None, item_path=None, item_name=None, content=None, item_user=None)

        model.new_comment(session.user.name, inp.item_host, inp.item_path, inp.item_name, inp.content, inp.item_user)

        page_owner = model.get_user(name=inp.item_user)
        if page_owner.mailmode == "all":
            web.sendmail(
                'Comment on This! <*****@*****.**>',
                page_owner.email,
                '[CoT] New comment on '+get_domain(inp.item_host),
                session.user.name+" posted a comment on "+inp.item_host+inp.item_path+"#"+inp.item_name+":"+
                "\n\n"+inp.content+
                "\n\n    -- The Comment on This Team"
            )

        if inp.close_after:
            return render.comment_thanks()
        else:
            raise web.seeother(
                "/comment"+
                "?item_host="+web.urlquote(inp.item_host)+
                "&item_path="+web.urlquote(inp.item_path)+
                "&item_name="+web.urlquote(inp.item_name)
            )
Пример #2
0
 def POST(self, blogid):
     form = self.form()
     if not form.validates():
         post = model.get_post(int(blogid))
         comments = model.get_comments(int(blogid))
         return render.view(post, comments, form)
     else:
         model.new_comment(blogid, form.d.author, form.d.comment)
         web.seeother("/view/" + blogid)
Пример #3
0
    def POST(self,id):
        form = web.input(content={})    #获取用户评论输入
        content = form['content']
        user = utils.getuser_by_cookie()

        if not user:
            print 'no user'
            return '请登录再评论'
        #插入数据库
        model.new_comment(id,user['name'],user['image'],content)
Пример #4
0
	def POST(self, post_id):
		i = web.input(author='', email='', url=None, comment='', reply_notify_mail=None)

		# TODO validate email format, and also do it in html javascript.
		if i.author and i.email and i.comment: 
			model.new_comment(post_id, i.author, web.ctx.ip, web.ctx.env['HTTP_USER_AGENT'], i.comment, i.url, i.email, i.reply_notify_mail=='on')

			# TODO difference between seeother and redirect.
			raise web.seeother('/post/' + post_id)
		else:
			# TODO: show error message.
			return render.post(post_id)
Пример #5
0
def add_comment(subject, value):
    if request.get_cookie("username", secret='m14AGroup6'):
        comment = html.escape(request.forms.get("comment"))
        username = request.get_cookie("username", secret='m14AGroup6')
        title = html.escape(request.forms.get("title"))
        unit = html.escape(request.forms.get("unit"))
        if len(title) > 100 or len(username) > 10 or len(comment) > 250:
            return model.error("Length Error")
        if unit != subject:
            return model.error("Length Error")
        return model.new_comment(subject, title, comment, username)
    else:
        return model.login()
Пример #6
0
 def POST(self, post_id):
     post, user = model.view_post(post_id)
     f = form.post_add_form()
     t = model.list_comment(post_id)
     if not f.validates():
         return render({'title': settings.SITE_NAME, 'make_html': util.make_html}).view(post, user, t, f)
     else:
         if f.d.id:
             post_id = model.new_comment(f.d.username, f.d.password, f.d.title, f.d.content, f.d.id)
             if post_id:
                 return web.redirect("/view/%d" % post_id)
             else:
                 return render().failed()
Пример #7
0
 def POST(self):
     form = self.form()
     if not form.validates():
         return render.new(form)
     model.new_comment(form.d.title, form.d.content)
     raise web.seeother('/')
Пример #8
0
	for post in posts:
		assert(post and post.author_id == 1 and post.title == 'title' and post.content == 'content' and post.excerpt== None and post.slug == None and post.post_type=='blog' and post.comment_status=='open' and post.post_status=='published')
	
	model.delete_post(post_id)
	model.delete_post(another_post_id)
	posts = model.get_posts()
	assert(not posts)
	
	post_id = model.new_post(1, 'title', 'content', None, None, 'blog', 'open', 'published', None, None)
	assert(post_id)

	for i in range(0, 10):
		author = 'author %d' %i
		content = 'comment %d' %i
		model.new_comment(post_id, author, '192.168.1.1', 'firefox 4.0', content)

	comments = model.get_comments()
	assert(comments and len(comments) == 10 and model.get_comment_num(post_id) == 10)

	ci = 9 
	for c in comments:
		assert(c.post_id == post_id and c.author == 'author %d' %ci and c.author_ip == '192.168.1.1' and c.comment_agent == 'firefox 4.0' and c.content == 'comment %d' %ci and c.url == None and c.email == None and c.reply_notify_mail == False)
		ci -= 1

	############start test category, now there is only default category.
	cid1 = model.new_category('category 1', 0, 'description 1')

	categories = model.get_all_categories()

	assert(len(categories) == 2 and cid1 > 0)