예제 #1
0
 def article_delete(self, request):
     user = endpoints.get_current_user()
     article = Article.get_article(request.value)
     if not(user and article and user.email() == article.author_email):
         return API.BooleanMessage(value=False)
     article.delete()
     return API.BooleanMessage(value=True)
예제 #2
0
 def article_edit(self, request):
     user = endpoints.get_current_user()
     article = Article.get_article(request.id)
     if not(user and article and user.email() == article.author_email):
         return API.BooleanMessage(value=False)
     article.edit(request.title, request.content)
     return API.BooleanMessage(value=True)
예제 #3
0
 def article_toggle_dislike(self, request):
     user = endpoints.get_current_user()
     article = Article.get_article(request.value)
     if not(user and article):
         return API.BooleanMessage(value=False)
     article.toggle_dislike(user.email())
     return API.BooleanMessage(value=True)
예제 #4
0
 def article_comment(self, request):
     user = endpoints.get_current_user()
     article = Article.get_article(request.id)
     if not(user and article):
         return API.IntegerMessage(value=-1)
     return API.IntegerMessage(value=article.comment(user.email(), request.content))
예제 #5
0
 def article_get_comments(self, request):
     article = Article.get_article(request.value)
     if not article:
         return comment_api.MultiCommentResponse(comments=[])
     comments = [comment_api.createCommentMessage(comment) for comment in article.get_comments()]
     return comment_api.MultiCommentResponse(comments=comments)
예제 #6
0
 def article_get(self, request):
     article = Article.get_article(request.value)
     if not article:
         return ArticleResponse()
     return ArticleResponse(article=createArticleMessage(article))