예제 #1
0
파일: admin.py 프로젝트: friendwu/xwp2
	def GET(self, post_id):
		# get from QUERY_STRING
		i = web.input(message=MESSAGE_NONE)

		#TODO validate post_id in html?
		#TODO how to accept *args/**kargs in template?
		return admin_render.post(post_id, None, i.message)
예제 #2
0
파일: admin.py 프로젝트: friendwu/xwp2
	def POST(self): 
		i = web.input(author_id=None, title=None, 
					  content=None, excerpt=None, 
					  slug=None, post_type='blog', 
					  comment_status='open', post_status='published', 
					  tags=[], categories=[])
	
		#TODO author id	
		#TODO slug 
		if i.slug == '': i.slug = None
		i.author_id = 1
		if i.title and i.content: # and i.author_id:
			insert_id = model.new_post(i.author_id, i.title, 
									   i.content, i.excerpt,
									   i.slug, i.post_type, 
									   i.comment_status, i.post_status, 
									   i.tags, i.categories)
			if insert_id:
				raise web.seeother("/admin/edit-post/%d?message=%s" % (insert_id, MESSAGE_NEW_POST_DONE))
			else:
				return admin_render.post(None, i, MESSAGE_NEW_POST_ERROR)
		else:
			return admin_render.post(None, i, MESSAGE_NEED_TITLE_OR_CONTENT)
예제 #3
0
파일: admin.py 프로젝트: friendwu/xwp2
	def POST(self, post_id): 
		# get from http post form data.
		i = web.input(author_id=None, title=None, 
					  content=None, excerpt=None, 
					  slug=None, post_type='blog', 
					  comment_status='open', post_status='published', 
					  tags=[], categories=[])
		
		#TODO author id	
		#TODO slug 
		if i.slug == '': i.slug = None
		i.author_id = 1

		values = dict(i)
		values.pop('submit')
	
		
		if model.update_post(post_id, **values):
			raise web.seeother("/admin/edit-post/%d?message=%s" % (post_id, MESSAGE_UPDATE_DONE))
		else:
			return admin_render.post(post_id, i, MESSAGE_UPDATE_ERROR)
예제 #4
0
파일: admin.py 프로젝트: friendwu/xwp2
	def GET(self):
		return admin_render.post(None, None, MESSAGE_NONE)