Ejemplo n.º 1
0
	def POST(self):
		i = web.input(del_category_array=[])

		for cid in i.del_category_array:
			if not model.delete_category(cid):
				raise web.seeother('/admin/admin-categories?message=delete category failed.')
		
		raise web.seeother('/admin/admin-categories/?message=delete category done.')
Ejemplo n.º 2
0
import model
"""
now its just in smoke test level.
"""

if __name__ == '__main__':
	#clear data
	for i in range(1,100):
		model.delete_post(i)
	for j in range(3, 100):
		model.delete_category(j)

	post_id = model.new_post(1, 'title', 'content', None, None, 'blog', 'open', 'published', None, None)
	assert(post_id)
	
	post = model.get_post(post_id)

	assert(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')

	c = model.get_post_categories(post_id)
	assert(len(c) == 1 and c[0].name == 'uncategorized' and c[0].parent_id == 0 and c[0].id == 1 and c[0].description == '' and c[0].type=='post_category')
	
	# test tag. TODO.
	assert(model.update_post(post_id, author_id=2, title='new title', content='new content', comment_status='close', post_status='saved'))
	
	post = model.get_post(post_id)
	assert(post.author_id == 2 and post.title == 'new title' and post.content == 'new content' and post.excerpt== None and post.slug == None and post.post_type=='blog' and post.comment_status=='close' and post.post_status=='saved')
	
	assert(model.update_post(post_id, author_id=1, title='title', content='content', comment_status='open', post_status='published'))

	another_post_id = model.new_post(1, 'title', 'content', None, None, 'blog', 'open', 'published', None, None)