예제 #1
0
    def test_get_comments(self):
        thread, a1, a2, tempdir = self._create_comments()

        # the DB allows you to get comments for a given article
        comments = CommentsDB(tempdir)
        res = list(comments.get_comments(a1.article_uuid))
        self.assertEqual(len(res), 2)
예제 #2
0
파일: comments.py 프로젝트: AcrDijon/henet
def get_comment():
    def add_summary(comment):
        if len(comment.text) > 20:
            comment.summary = comment.text[:20] + '...'
        else:
            comment.summary = comment.text

        comment.html = rst2html(comment.text, theme='acr', body_only=True)
        return comment

    comments_dir = app._config['henet']['comments_dir']
    database = CommentsDB(comments_dir)
    comments = [add_summary(comment) for comment in
                database.get_moderation_queue()]

    return {'now': datetime.datetime.now(),
            "csrf_token": request.csrf_token,
            'comments': comments, 'category': 'comments'}
예제 #3
0
    def test_get_moderation_queue(self):
        thread, a1, a2, tempdir = self._create_comments()

        # let's check the moderation queue
        comments = CommentsDB(tempdir)

        # let's moderate our articles
        cuids = [c.uuid for c in comments.get_moderation_queue()]
        comments.activate_comment(cuids[0])
        comments.reject_comment(cuids[1])

        # noop
        comments.activate_comment("xxx")

        # the queue should be empty now
        self.assertEqual(len(list(comments.get_moderation_queue())), 0)

        # let's check we have 3 active comments now in that thread
        thread.load()
        comments = thread.get_comments()
        self.assertEqual(len(comments), 3)
예제 #4
0
파일: comments.py 프로젝트: AcrDijon/henet
def reject_comment(comment_id):
    comments_dir = app._config['henet']['comments_dir']
    database = CommentsDB(comments_dir)
    database.reject_comment(comment_id)
    redirect('/comments')
예제 #5
0
파일: comments.py 프로젝트: AcrDijon/henet
def activate_comment(comment_id):
    comments_dir = app._config['henet']['comments_dir']
    database = CommentsDB(comments_dir)
    database.activate_comment(comment_id)
    redirect('/comments')