コード例 #1
0
ファイル: article.py プロジェクト: hellodhlyn/Yuzuki
 def render_GET(self, request):
     board_name = request.get_argument("name")
     board = get_board(request, board_name)
     if not can_write(request, board):
         raise Unauthorized()
     context = {"board": board}
     return render_template("article_write.html", request, context)
コード例 #2
0
ファイル: article.py プロジェクト: hellodhlyn/Yuzuki
 def render_GET(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if is_author(request, article):
         context = {"article": replaceArticleContentForEdit(article)}
         return render_template("article_edit.html", request, context)
     else:
         raise Unauthorized()
コード例 #3
0
ファイル: article.py プロジェクト: hellodhlyn/Yuzuki
 def render_DELETE(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if is_author_or_admin(request, article):
         delete_article(request, article)
         request.dbsession.commit()
         return "delete success"
     else:
         raise Unauthorized()
コード例 #4
0
 def render_DELETE(self, request):
     reply_id = request.get_argument("id")
     reply = get_reply(request, reply_id)
     if is_author_or_admin(request, reply):
         delete_reply(request, reply)
         request.dbsession.commit()
         return "success"
     else:
         raise Unauthorized()
コード例 #5
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()
コード例 #6
0
 def render_POST(self, request):
     reply_id = request.get_argument("id")
     reply = get_reply(request, reply_id)
     if is_author(request, reply):
         content = request.get_argument("content")
         if content.strip():
             edit_reply(request, reply, content)
             request.dbsession.commit()
             return "reply edit success"
         else:
             raise BadRequest()
     else:
         raise Unauthorized()
コード例 #7
0
ファイル: article.py プロジェクト: Perlmint/Yuzuki
 def render_POST(self, request):
     board_name = request.get_argument("name")
     board = get_board(request, board_name)
     if not can_write(request, board):
         raise Unauthorized()
     subject = request.get_argument("subject")
     content = request.get_argument("content")
     # no empty subject
     if subject.strip():
         article = create_article(request, board, subject, content)
         request.dbsession.add(article)
         request.dbsession.commit()
         request.redirect("/article/view?id=%s" % article.uid)
         return "article posted"
     else:
         raise BadRequest()
コード例 #8
0
ファイル: article.py プロジェクト: Perlmint/Yuzuki
 def render_POST(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if is_author(request, article):
         subject = request.get_argument("subject")
         content = request.get_argument("content")
         # no empty subject
         if subject.strip():
             edit_article(request, article, subject, content)
             request.dbsession.commit()
             request.redirect("/article/view?id=%s" % article.uid)
             return "article edit success"
         else:
             raise BadRequest()
     else:
         raise Unauthorized()
コード例 #9
0
ファイル: article.py プロジェクト: hellodhlyn/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()
コード例 #10
0
    def render_POST(self, request):
        if not request.user:
            raise Unauthorized()
        nickname = request.get_argument("nickname") or None
        password = request.get_argument("password") or None
        pd_realname = request.get_argument("pd_realname") or None
        pd_email = request.get_argument("pd_email") or None
        pd_address = request.get_argument("pd_address") or None
        pd_phone = request.get_argument("pd_phone") or None
        pd_bio = request.get_argument("pd_bio") or None
        slack_id = request.get_argument("slack_id") or None

        # error check
        err = None
        if nickname:
            query = request.dbsession.query(User)\
                                     .filter(User.nickname == nickname)
            if request.dbsession.query(query.exists()).scalar():
                err = u"이미 사용되고 있는 별명입니다."
            elif not re.match(u"^[-_a-zA-Z가-힣\\d\\(\\)]{1,}$", nickname):
                err = u"별명은 영문, 한글, 숫자, 붙임표(-), 밑줄(_)과 괄호만 사용할 수 있습니다."

        if err:
            context = {"err": err}
            request.setResponseCode(BAD_REQUEST)
            return render_template("profile_edit.html", request, context)

        if nickname:
            request.user.nickname = nickname
        if password:
            request.user.password = pbkdf2(password)
        if pd_realname:
            request.user.pd_realname = pd_realname
        if pd_email:
            request.user.pd_email = pd_email
        if pd_address:
            request.user.pd_address = pd_address
        if pd_phone:
            request.user.pd_phone = pd_phone
        if pd_bio:
            request.user.pd_bio = markdown_and_linkify(pd_bio)
        if slack_id is not None:
            request.user.slack_id = slack_id

        request.dbsession.commit()
        request.redirect("/profile/view")
        return "profile edit success"
コード例 #11
0
 def render_POST(self, request):
     article_id = request.get_argument("article_id")
     article = get_article(request, article_id)
     if not can_comment(request, article.board):
         raise Unauthorized()
     content = request.get_argument("content")
     # no empty reply
     if content.strip():
         reply = create_reply(request, article, content)
         request.dbsession.add(reply)
         request.dbsession.commit()
         page = request.get_argument("page", None)
         redirect = "/article/view?id=%s" % article.uid
         if page:
             redirect += "&page=%s" % page
         request.redirect(redirect)
         return "success"
     else:
         raise BadRequest()
コード例 #12
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)
コード例 #13
0
ファイル: article.py プロジェクト: hellodhlyn/Yuzuki
 def render_POST(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if is_author(request, article):
         subject = request.get_argument("subject")
         content = request.get_argument("content")
         # no empty subject
         if subject.strip():
             edit_article(request, article, subject, content)
             request.dbsession.commit()
             redirect_url = "/article/view?id=%s" % article.uid
             request.redirect(redirect_url)
             post_messages_to_subscribers(request,
                                          article.subscribing_users,
                                          u"구독하고 있는 글이 수정되었습니다.",
                                          article.user, article.subject,
                                          article.compiled_content,
                                          redirect_url)
             return "article edit success"
         else:
             raise BadRequest()
     else:
         raise Unauthorized()
コード例 #14
0
 def render_POST(self, request):
     article_id = request.get_argument("article_id")
     article = get_article(request, article_id)
     if not can_comment(request, article.board):
         raise Unauthorized()
     content = request.get_argument("content")
     # no empty reply
     if content.strip():
         reply = create_reply(request, article, content)
         request.dbsession.add(reply)
         request.dbsession.commit()
         page = request.get_argument("page", None)
         redirect = "/article/view?id=%s" % article.uid
         if page:
             redirect += "&page=%s" % page
         post_messages_to_subscribers(request, article.subscribing_users,
                                      u"구독하고 있는 글에 새 댓글이 등록되었습니다.",
                                      reply.user, article.subject, content,
                                      redirect)
         request.redirect(redirect)
         return "success"
     else:
         raise BadRequest()
コード例 #15
0
ファイル: resource.py プロジェクト: hellodhlyn/Yuzuki
 def _render_wrapper(resource, request):
     if not request.user or not request.user.is_admin:
         raise Unauthorized()
     else:
         return f(resource, request)
コード例 #16
0
ファイル: resource.py プロジェクト: hellodhlyn/Yuzuki
 def _render_wrapper(resource, request):
     if request.user and is_anybody(request):
         return f(resource, request)
     else:
         raise Unauthorized()
コード例 #17
0
ファイル: profile.py プロジェクト: Perlmint/Yuzuki
 def render_GET(self, request):
     if not request.user:
         raise Unauthorized()
     return render_template("profile_edit.html", request)