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 GET(self, board_name):
        if board_name == '*' or board_name == '^root':
            v = board_actions()
            return v.subboard_list_get()

        board_id = board._get_board_id_from_path(board_name)
        if board_id < 0:
            #try to find regex match
            board_id = board._get_board_id_from_regex_path(board_name)
            if board_id < 0:
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error'))
            else:
                path = board._get_path_from_board_id(board_id)
                raise web.seeother(util.link(path))

        board_info = board.get_board_info(board_id)
        if board_info.bType == 0: # 디렉터리
            v = board_actions()
            return v.subboard_list_get(board_name, board_id)
        elif board_info.bType == 2: # 넘겨주기
            board_id = board._get_board_id_from_path(board_info.bDescription)
            if board_id < 0 or board_info.bDescription.strip() == '':
                raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_ALIAS'), help_context='error'))
            else:
                raise web.seeother(util.link(board_info.bDescription))

        #processing new_article
        if web.ctx.session.has_key('uid'):
            uid = web.ctx.session.uid
            user.update_unreaded_articles_board(uid, board_id)

        qs = web.ctx.query
        if len(qs) > 0:
            qs = qs[1:]
            qs = parse_qs(qs)


        t = article._get_total_page_count(board_id, config.page_size)
        if qs:
            page = int(qs['page'][0])
        else:
            page = t

        a = article.get_article_list(board_id, config.page_size, page)
        m = article.get_marked_article(board_id)

        return util.render().board(lang="ko",
            title = board_info.bName,
            board_path = board_info.bName[1:],
            board_desc = board_info.bDescription,
            stylesheet = board_info.stylesheet,
            articles=a, marked_articles = m,
            total_page = t, page = page, feed = True,
            help_context = 'board')
Beispiel #3
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 #4
0
    def all_get(self, board_name, board_id, current_uid = -1):
        board_id = board._get_board_id_from_path(board_name)
        if board_id < 0:
            path = board._get_path_from_board_id(board_id)
            raise web.seeother(util.link(path))

        board_info = board.get_board_info(board_id)
        board_name = board_info.bName;

        if web.ctx.session.has_key('uid'):
            uid = web.ctx.session.uid
            user.update_unreaded_articles_board(uid, board_id)

        qs = web.ctx.query
        if len(qs) > 0:
            qs = qs[1:]
            qs = parse_qs(qs)

        t = article._get_recurse_page_count(board_name, config.page_size)
        if qs:
            page = int(qs['page'][0])
        else:
            page = t

        a = article.get_recurse_article_list(board_name, 
            config.page_size, page)
        m = article.get_marked_article(board_id)

        return util.render().board(lang="ko",
            title = board_info.bName,
            board_path = board_info.bName[1:],
            board_desc = board_info.bDescription,
            stylesheet = board_info.stylesheet,
            articles=a, marked_articles = m,
            total_page = t, page = page, feed = True,
            help_context = 'board')