Beispiel #1
0
    def write_post(self, board_name, board_id, current_uid = -1):
        a = dict(title = web.input().title, body = web.input().content)
        board_info = board.get_board_info(board_id)
        ret = article.write_article(current_uid, board_id, a)
        if ret[0] == True:
            user.update_unreaded_articles_board(current_uid, board_id)
            user.read_article(current_uid, ret[1])

            fs = web.ctx.get('_fieldstorage')
            try:
                if fs.has_key('new_attachment'):
                    new_attachment = fs['new_attachment']
                    if type(new_attachment) == list:
                        for f in new_attachment:
                            attachment.add_attachment(ret[1], f.filename, f.value)
                    else:
                        try:
                            attachment.add_attachment(ret[1], new_attachment.filename, new_attachment.value)
                        except:
                            pass
            except:
                pass
            url = util.link('/%s/+read/%s' % (board_name, ret[1]))
            raise web.seeother(url)
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #2
0
    def comment_post(self, board_name, board_id, article_id, current_uid = -1):
        if not acl.is_allowed('board', board_id, current_uid, 'comment'):
            return util.render().error(error_message=_('NO_PERMISSION'), help_context='error')
        comment = web.input().comment
        board_info = board.get_board_info(board_id)
        ret = article.write_comment(current_uid, board_id, article_id, comment)
        if ret[0] == True:
            user.update_unreaded_articles_board(current_uid, board_id)
            user.read_article(current_uid, ret[1])

            raise web.seeother(util.link('/%s/+read/%s') % (board_name, article_id))
        else:
            return util.render().error(error_message = ret[1], help_context='error')
Beispiel #3
0
    def read_get(self, board_name, board_id, article_id):
        board_info = board.get_board_info(board_id)
        board_desc = board_info.bDescription
        a = article.get_article(board_id, article_id)
        comment = article.get_comment(article_id)

        #새글읽기 처리
        if web.ctx.session.has_key('uid'):
            uSerial = web.ctx.session.uid
            user.read_article(uSerial, article_id) 

        read_articles = web.cookies().get('read_articles')
        if read_articles:
            try:
                read_articles = [int(i) for i in read_articles.split(';')]
                if article_id not in read_articles:
                    article.increase_read_count(article_id)
                    read_articles.append(article_id)
            except ValueError:
                read_articles = []
        else:
            article.increase_read_count(article_id)
            read_articles = [article_id]
        read_articles.sort()
        read_articles = ';'.join(['%s' % i for i in read_articles])
        web.setcookie('read_articles', read_articles, 3600)

        prev_id = -1
        next_id = -1

        if not a:
            raise web.notfound(util.render().error(error_message = _('NO_SUCH_ARTICLE'), help_context='error'))
        if a.aIndex > 1:
            prev_id = article.get_article_id_by_index(board_id, a.aIndex - 1)
        if a.aIndex < article._get_article_count(board_id):
            next_id = article.get_article_id_by_index(board_id, a.aIndex + 1)
        page_no = article.get_page_by_article_id(board_id, article_id, config.page_size)
        uploads = attachment.get_attachment(article_id)
        thumbs = attachment.get_thumbnail(article_id, web.config.theme)

        return util.render().article(article = a,
            title = u"%s - %s" % (a.aIndex, a.aTitle),
            stylesheet = board_info.stylesheet,
            board_path = board_name, board_desc = board_desc,
            comments = comment, page_no = page_no,
            prev_id = prev_id, next_id = next_id, feed = True,
            attachment = uploads, thumbnail = thumbs,
            help_context = 'read_article')