コード例 #1
0
ファイル: admin.py プロジェクト: friendwu/xwp2
	def POST(self, cid):
		i = web.input(name='', description='', parent_id=0)

		if not i.name:
			return admin_render.category(cid, i, 'name must be provided.')
		elif model.update_category(name=i.name, description=i.description, parent_id=i.parent_id):
			return admin_render.category(cid, i, 'category update ok.')
コード例 #2
0
ファイル: test_model.py プロジェクト: friendwu/xwp2
		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))
	assert(len(model.get_all_categories()) == 1)