コード例 #1
0
    def get_articles_by_date(self, request):
        next = None
        bookmark = request.date

        if bookmark:
            some_articles = main.Articles().all().order("-date").filter(
                'date <=', parser.parse(bookmark)).fetch(request.limit + 1)
        else:
            some_articles = main.Articles().all().order("-date").fetch(
                request.limit + 1)
        if len(some_articles) == request.limit + 1:
            next = str(some_articles[-1].date)
        some_articles = some_articles[:request.limit]
        articles = []
        for article in some_articles:
            articles.append(
                Article(id=article.key().id(),
                        embed=article.embed,
                        title=article.title,
                        author=article.author,
                        view=article.view,
                        content=article.content,
                        tags=article.tags,
                        date=str(article.date)))

        return Articles(articles=articles, next=next)
コード例 #2
0
 def delete_comment(self, request):
     article = main.Articles(parent=main.archive_key()).get_by_id(
         request.article_id, parent=main.archive_key())
     pickled = main.db.Text(dumps(['deleted', '', datetime.now()]))
     article.comments[request.comment_id] = pickled
     article.put()
     return message_types.VoidMessage()
コード例 #3
0
 def set_article_view(self, request):
     article = main.Articles(parent=main.archive_key()).get_by_id(
         request.id, parent=main.archive_key())
     #if article.author == main.users.get_current_user(): #old-style
     if article.author == main.oAuthUsers.get_current_user():
         article.view = request.view
         article.put()
         return ErrorInfo()
     return ErrorInfo(error_code=1,
                      error_info='signed in user is not the author')
コード例 #4
0
 def post_article(self, request):
     article = main.Articles(parent=main.archive_key())
     #article.author = main.users.get_current_user()
     article.author = main.oAuthUsers.get_current_user()
     article.embed = request.embed
     article.title = request.title
     article.content = request.content
     article.tags = request.tags
     article.view = "Preview"
     article.put()
     return message_types.VoidMessage()
コード例 #5
0
 def edit_comment(self, request):
     article = main.Articles(parent=main.archive_key()).get_by_id(
         request.article_id, parent=main.archive_key())
     #nickname = main.users.get_current_user() #old-style
     nickname = main.oAuthUsers.get_current_user().nickname()
     pickled = main.db.Text(
         dumps([request.comment_text, nickname,
                datetime.now()]))
     article.comments[request.comment_id] = pickled
     article.put()
     return message_types.VoidMessage()
コード例 #6
0
 def post_comment(self, request):
     article = main.Articles(parent=main.archive_key()).get_by_id(
         request.article_id, parent=main.archive_key())
     #nickname = main.users.get_current_user() #old-style
     nickname = main.oAuthUsers.get_current_user().nickname()
     pickled = main.db.Text(
         dumps([request.comment_text, nickname,
                datetime.now()]))
     article.comments.append(pickled)
     article.put()
     comment_id = len(article.comments) - 1
     return CommentInfo(comment_id=comment_id,
                        user_url='todo',
                        user_activity='todo',
                        nickname=str(nickname))