コード例 #1
0
ファイル: admin.py プロジェクト: friendwu/xwp2
	def POST(object):
		i = web.input(name=None, parent_id=0, description='')
		
		if i.name:
			cid = model.new_category(name=i.name, 
							  parent_id=i.parent_id, 
							  description=i.description)
		if cid:
			web.seeother('/admin/edit-category/%d?message="new category done."', cid)
		else:
			return admin_render.category(None, i, 'new category error.')
コード例 #2
0
ファイル: test_model.py プロジェクト: friendwu/xwp2
	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)

	for c in categories:
		if cid1 == c.id:
			assert(c.name == 'category 1' and c.parent_id == 0 and c.description == 'description 1')
	
	assert(model.update_category(cid1, name='new category 1', description='new description 1', parent_id=1))
	
	c1 = model.get_category(cid1)
	assert (c1.name == 'new category 1' and c1.parent_id == 1 and c1.description == 'new description 1')
	
	assert(model.delete_category(cid1))