Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 def render_POST(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if request.user in article.subscribing_users:
         article.subscribing_users.remove(request.user)
     else:
         article.subscribing_users.append(request.user)
     request.dbsession.commit()
     return json.dumps(request.user in article.subscribing_users)
Ejemplo n.º 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()
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
0
 def render_POST(self, request):
     article_id = request.get_argument("id")
     article = get_article(request, article_id)
     if request.user in article.subscribing_users:
         article.subscribing_users.remove(request.user)
     else:
         article.subscribing_users.append(request.user)
     request.dbsession.commit()
     return json.dumps(request.user in article.subscribing_users)
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
 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()
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
 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()
Ejemplo n.º 11
0
 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()
Ejemplo n.º 12
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()
Ejemplo n.º 13
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()
Ejemplo n.º 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
         request.redirect(redirect)
         return "success"
     else:
         raise BadRequest()
Ejemplo n.º 15
0
 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()
Ejemplo n.º 16
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()
Ejemplo n.º 17
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()
Ejemplo n.º 18
0
 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()