예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
파일: reply.py 프로젝트: HelloDHLyn/Yuzuki
 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()
예제 #4
0
 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()
예제 #5
0
파일: template.py 프로젝트: Pusnow/Yuzuki
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)
예제 #6
0
파일: article.py 프로젝트: box327/Yuzuki
 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()
예제 #7
0
 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()
예제 #8
0
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)
예제 #9
0
파일: board.py 프로젝트: Perlmint/Yuzuki
 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)
예제 #10
0
파일: board.py 프로젝트: HelloDHLyn/Yuzuki
 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)
예제 #11
0
 def _render_wrapper(resource, request):
     if request.user and is_anybody(request):
         return f(resource, request)
     else:
         raise Unauthorized()