def render_template(name, request, context=None): if context is None: context = dict() context["side_menu"] = SIDE_MENU context["request"] = request context["is_anybody"] = is_anybody(request) return get_template(name).render(context)
def render_GET(self, request): article_id = request.get_argument("article_id") page = request.get_argument_int("page", 1) article = get_article(request, article_id) if article.board.name == "notice" or (is_anybody(request)): replies = get_reply_page(request, article, page) return json.dumps([reply.to_dict() for reply in replies]) else: raise Unauthorized()
def render_template(name, request, context=None): if context == None: context = dict() board_query = request.dbsession.query(Board).filter(Board.enabled).order_by(Board.repr_order.asc()) board_meta = { "somoim": [(board.name, board.repr) for board in board_query.filter(Board.classification == "somoim")], "normal": [(board.name, board.repr) for board in board_query.filter(Board.classification == "normal")], } context["board_meta"] = board_meta context["request"] = request context["is_anybody"] = is_anybody(request) return get_template(name).render(context)
def render_GET(self, request): article_id = request.get_argument("id") article = get_article(request, article_id) page = request.get_argument("page", None) if article.board.name == "notice" or is_anybody(request): reply_page_total = article.reply_count / REPLY_PER_PAGE if article.reply_count % REPLY_PER_PAGE != 0: reply_page_total += 1 context = {"article": article, "page": page, "reply_page_total": reply_page_total} return render_template("article_view.html", request, context) else: raise Unauthorized()
def render_GET(self, request): article_id = request.get_argument("id") article = get_article(request, article_id) page = request.get_argument("page", None) if article.board.name == "notice" or is_anybody(request): reply_page_total = article.reply_count / REPLY_PER_PAGE if article.reply_count % REPLY_PER_PAGE != 0: reply_page_total += 1 context = { "article": article, "page": page, "reply_page_total": reply_page_total, } return render_template("article_view.html", request, context) else: raise Unauthorized()
def render_template(name, request, context=None): if context == None: context = dict() board_query = request.dbsession.query(Board).filter( Board.enabled).order_by(Board.repr_order.asc()) board_meta = { "somoim": [(board.name, board.repr) for board in board_query.filter(Board.classification == "somoim")], "normal": [(board.name, board.repr) for board in board_query.filter(Board.classification == "normal")], } context["board_meta"] = board_meta context["request"] = request context["is_anybody"] = is_anybody(request) return get_template(name).render(context)
def render_GET(self, request): name = request.get_argument("name") if not (name == "notice" or is_anybody(request)): raise Unauthorized() page = request.get_argument_int("page", 1) board = get_board(request, name) articles = get_article_page(request, board, page) total_article_count = board.article_count page_total = total_article_count / ARTICLE_PER_PAGE if total_article_count % ARTICLE_PER_PAGE != 0: page_total = total_article_count / ARTICLE_PER_PAGE + 1 context = { "items": articles, "board": board, "page": page, "page_total": page_total, "can_write": can_write(request, board), } return render_template("board.html", request, context)
def _render_wrapper(resource, request): if request.user and is_anybody(request): return f(resource, request) else: raise Unauthorized()