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)
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)
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)
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))
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)
def article_get(self, request): article = Article.get_article(request.value) if not article: return ArticleResponse() return ArticleResponse(article=createArticleMessage(article))