예제 #1
0
	def get(self, post_id_str):
		post_id = int(post_id_str)

		post_key = models.Post.get_key(post_id)

		post = post_key.get()
		if post:
			if post.parent_thread is None:
				user_ban_rpc = self.user_is_banned_async()
				comment_text = self.request.GET.get('comment', '')

				db_writes_enabled = config.DB_WRITE_CAPABILITY.is_enabled()

				child_posts_rpc = models.Post.get_child_posts_async(post_key)
				user_ban = user_ban_rpc.get_result()
				if db_writes_enabled and not user_ban[0]:
					upload_url_rpc = blobstore.create_upload_url_async("/post/%d/reply/%s" % (post_id, int(self.user_ip)), max_bytes_per_blob=config.MAX_FILE_SIZE_BYTES, max_bytes_total=config.MAX_FILE_SIZE_BYTES)

					self.render_response('post_view.html', main_post=post, upload_url=utils.clean_dev_url(upload_url_rpc.get_result()), child_posts=child_posts_rpc.get_result(), comment=comment_text, db_writes_enabled=db_writes_enabled)
				else:
					self.render_response('post_view.html', main_post=post, child_posts=child_posts_rpc.get_result(), comment=comment_text, db_writes_enabled=db_writes_enabled)
			else:
				if 'comment' in self.request.GET:
					self.redirect('/post/%d?comment=%s#%d' % (post.parent_thread.id(), self.request.GET['comment'], post_id))
				else:
					self.redirect('/post/%d#%d' % (post.parent_thread.id(), post_id))
		else:
			self.abort(404)
예제 #2
0
	def get(self):
		index_threads_rpc = models.Post.get_index_page_async()
		user_ban_rpc = self.user_is_banned_async()

		db_writes_enabled = config.DB_WRITE_CAPABILITY.is_enabled()

		user_ban = user_ban_rpc.get_result()
		if db_writes_enabled and not user_ban[0]:
			upload_url_rpc = blobstore.create_upload_url_async("/new-thread/%s" % int(self.user_ip), max_bytes_per_blob=config.MAX_FILE_SIZE_BYTES, max_bytes_total=config.MAX_FILE_SIZE_BYTES)

			self.render_response('index.html', upload_url=utils.clean_dev_url(upload_url_rpc.get_result()), threads=index_threads_rpc.get_result(), db_writes_enabled=db_writes_enabled)
		else:
			self.render_response('index.html', threads=index_threads_rpc.get_result(), db_writes_enabled=db_writes_enabled)