Example #1
0
	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)
Example #2
0
	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)
Example #3
0
	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)
Example #4
0
	def GET(self):
		return admin_render.post(None, None, MESSAGE_NONE)