Beispiel #1
0
def edit(id):
	blogs = functions.get_model('blogm')
	if request.method == 'GET':
		p = blogm.get(blogs.c.id==id)
		form = blogform(data = p.to_dict(),action="/update/%s" %id)
		print form
		return {'form':form}
Beispiel #2
0
def index1():
#	blogs = functions.get_model('blogm')
#	blog = blogs.all()

	form = blogform()

	if request.method == 'POST':
		for i in request.params.keys():
			print i,request.params[i]
#		n         = blogm()
#		n.name    = request.params["name"]
#		n.content = request.params["content"]
#		n.save()
		flag = form.validate(request.params)
		if flag:
			n = blogm(**form.data)
			n.save()

	blog_all = blogform()
	blogm_all = blogm.all()
	return {"blog":blog_all,"blogm_all":blogm_all}
Beispiel #3
0
def index_delete(ida):
	form = blogform()
	
	if hasattr(request, 'user') and request.user:
		pass
	else:
		return redirect('/login')
	
	if request.method == 'GET':
		n = blogm()
		n.filter(n.c.id==ida).remove()
		
	return redirect('/')
Beispiel #4
0
def update(id):
	form = blogform()
	flag = form.validate(request.params)
	n = blogm.get(blogm.c.id == id)
	if n:
		n.id       = id
		n.name     = request.user.username
		n.title    = form.data.title
		n.content  = form.data.content
		n.save()
		
#		n.id   = id
#		n.name = request.user.username
#		n      = blogm(**form.data)
#		n.save()

	return redirect('/');
Beispiel #5
0
def index_save():
	form = blogform()
	
	if hasattr(request, 'user') and request.user:
		pass
	else:
		return redirect('/alert')

	if request.method == 'POST':
		flag = form.validate(request.params)
		if flag:
			n      = blogm(**form.data)
			n.name = request.user.username
			n.save()
	
	
#	for i in request.params.keys():
#		print request.params[i]
#	return {}

	return redirect('/')
Beispiel #6
0
def index():
	form = blogform(action='/save')
	blogm_all = blogm.all()
	return {'form':form,'blogm_all':blogm_all}