Exemple #1
0
def new_thread(key=None):
	user = active_user()
	if has_permission(user,'new-thread'):
		new_thread = Thread()
		first_post = Post()
		name = bottle.request.forms.get("name")
		content = bottle.request.forms.get("content")
		tags = parse_tags(bottle.request.forms.get("tags",""))
		first_post.update({
			"owner":user.key,
			"content":content
		})
		new_thread.update({
			"name":name,
			"owner":user.key,
			"posts":[first_post.key],
			"tags":tags
		})
		forum = Forum.load(forum_key())
		target = Category.load(decrypt(key)) if key else forum
		target.threads.append(new_thread.key)
		target.save()
		new_thread.save()
		return flash_message("Your thread has been created.","/thread/"+new_thread.slug+"/","Success")
	raise bottle.HTTPError(404,
	"""Sorry, but we weren't able to find what you were looking for.
	  I hope that someday you do find it, but when you do, it won't be here.
	""")
Exemple #2
0
def new_thread_form(key=None):
	user = active_user()
	if has_permission(user,"new-thread"):
		forum = Forum.load(forum_key())
		target = Category.load(decrypt(key)) if key else forum
		return template("new_thread",target=target,user=user,forum=forum)
	raise bottle.HTTPError(404,
	"""Sorry, but we weren't able to find what you were looking for.
	  I hope that someday you do find it, but when you do, it won't be here.
	""")
Exemple #3
0
def category_page(key):
	key=decrypt(key)
	user=active_user()
	forum = Forum.load(forum_key())
	board = Category.load(key)
	if board.has_permission(user,'list'):
		data={}
		data['user']=user
		data['forum']=forum
		data['threads']=board.threads
		data['trends']=board.topics(user) or []
		data['tags'] = board.tags
		data['mode']='trending'
		return template("home",**data)
	return flash_message("No permission. :(","/","No permission.")