Exemplo n.º 1
0
 def recent_comments(self):
     comments = []
     for comment in Comment.recent_comments(10):
         text = markdown.markdown(
             comment.text,
             output_format='html5',
             safe_mode='replace',
         )
         comments.append((
             text,
             comment.user.id(),
             comment.user.get().username,
             comment.photo.id(),
             comment.format_date()
         ))
     return comments
Exemplo n.º 2
0
    def get(self):
        user_id, user = self.get_user()

        start = self.request.get('start')
        logging.info('start: %s', start)

        if not start:
            start = 0
        else:
            start = int(start)
            if start > 1000000:
                start = 0

        if start == 0:
            before = 0
            after = 10
        else:
            before = start - 10
            after = start + 10

        comments = list(Comment.recent_comments(10, start))
        logging.info(len(comments))
        more_old = '' if len(comments) == 10 else 'disabled'
        more_new = '' if start > 0 else 'disabled'

        data = {
            'page_title': 'Comments',
            'user': user,
            'comments': comments,
            'before': before,
            'after': after,
            'more_old': more_old,
            'more_new': more_new,
        }

        self.render('comments.html', **data)