def GET(self): if web.config.theme == 'm' or web.config.theme == 'n': v = board_actions() return v.subboard_list_get() else: child_board = board.get_child(1) notice_board_path = '/divisionCS/Notice' notice_board_id = board._get_board_id_from_path(notice_board_path) a = article.get_recent_article_list(notice_board_id, 5) student_notice_board_path = '/divisionCS/studentNotice' student_notice_board_id = board._get_board_id_from_path(student_notice_board_path) b = article.get_recent_article_list(student_notice_board_id, 5) freeboard_path = '/garbage' freeboard_id = board._get_board_id_from_path(freeboard_path) c = article.get_recent_article_list(freeboard_id, 5) undergraduate_path = '/divisionCS/undergraduate' undergraduate_id = board._get_board_id_from_path(undergraduate_path) d = article.get_recent_article_list(undergraduate_id, 5) return util.render().main(title = u'전산학과 BBS 노아입니다', lang='ko', board_desc = _('[KAIST CS BBS]'), board_path = '', child_boards = child_board, notice_board_path = notice_board_path, notice_articles = a, student_notice_board_path = student_notice_board_path, student_notice_articles = b, freeboard_path = freeboard_path, freeboard_articles = c, undergraduate_path = undergraduate_path, undergraduate_articles = d, help_context = 'main')
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')
def manage_subscription_post(self, current_uid = -1): data = web.input() favorite_add = False favorite_delete = False favorite_delete_list = [] favorite_name = '' subscription_add = False subscription_delete = False subscription_delete_list = [] subscription_name = '' for k in data.keys(): if k.startswith('favorite_delete_'): favorite_delete_list.append(int(k[16:])) elif k.startswith('subscription_delete_'): subscription_delete_list.append(int(k[20:])) elif k == 'favorite_add': favorite_add = True elif k == 'favorite_delete': favorite_delete = True elif k == 'favorite_name': favorite_name = data[k] elif k == 'subscription_add': subscription_add = True elif k == 'subscription_delete': subscription_delete = True elif k == 'subscription_name': subscription_name = data[k] if favorite_add == True: if favorite_name.strip() == '': raise web.seeother(util.link('/+u/+manage_subscription')) board_id = board._get_board_id_from_path(favorite_name) if board_id < 0: raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error')) user.add_favorite_board(current_uid, board_id) elif favorite_delete == True: for b in favorite_delete_list: user.remove_favorite_board(current_uid, b) elif subscription_add == True: if favorite_name.strip() == '': raise web.seeother(util.link('/+u/+manage_subscription')) board_id = board._get_board_id_from_path(subscription_name) if board_id < 0: raise web.notfound(util.render().error(lang='ko', error_message=_('INVALID_BOARD'), help_context='error')) user.add_subscription_board(current_uid, board_id) elif subscription_delete == True: for b in subscription_delete_list: user.remove_subscription_board(current_uid, b) raise web.seeother(util.link('/+u/+manage_subscription'))
def create_board_post(self, board_name, board_id, current_uid = -1): board_info = board.get_board_info(board_id) if not acl.is_allowed('board', board_id, current_uid, 'create'): return util.render().error(error_message = _('NO_PERMISSION'), help_context='error') user_data = web.input() comment = 1 if user_data.has_key('commentable') else 0 write_by_other = 1 if user_data.has_key('writable') else 0 indexable = 1 if user_data.has_key('indexable') else 0 show_avatar = 1 if user_data.has_key('show_avatar') else 0 owner_uid = user._get_uid_from_username(user_data.owner) if owner_uid < 0: return util.render().error(error_message=_('NO_SUCH_USER_FOR_BOARD_ADMIN'), help_context='error') if user_data.name.strip() == '': return util.render().error(error_message = _('NO_NAME_SPECIFIED'), help_context='error') if board_name == '^root': new_path = posixpath.join('/', user_data.name) else: new_path = posixpath.join('/', board_name, user_data.name) if board._get_board_id_from_path(new_path) > 0: return util.render().error(error_message = _('BOARD_EXISTS'), help_context='error') settings = dict(path=new_path, board_owner = owner_uid, cover = user_data.information, description = user_data.description, type = int(user_data.type), guest_write = write_by_other, can_comment = comment, indexable = indexable, show_avatar = show_avatar, current_uid = current_uid) ret = board.create_board(board_id, settings) if ret[0] == False: return util.render().error(error_message = ret[1] ,help_context = 'error') raise web.seeother(util.link('%s') % (new_path))
def caller(self, board_name, action, article_id, method): board_id = board._get_board_id_from_path(board_name) if board_id < 0: raise web.notfound(util.render().error(error_message = _('INVALID_BOARD'), help_context='error')) try: return eval('self.%s_%s' % (action, method))(board_name, board_id, int(article_id)) except AttributeError: raise web.notfound(util.render().error(error_message = _('INVALID_ACTION'), help_context='error'))
def get_type(path): if path == '^root': path = '/' id = board._get_board_id_from_path(path) if id < 0: return -1 data = board.get_board_info(id) return data.bType
def get_login_notice(notice_board = '/noah/welcome'): # /noah/welcome에서 공지 표시된 글 중 아무거나 하나를 랜덤으로 돌려 줌. # 공지 표시된 글이 없는 경우 '공지가 없습니다.'를 돌려 줌. articles = [] board_id = board._get_board_id_from_path(notice_board) if board_id < 0: return _('INVALID_NOTICE_BOARD') for i in article.get_marked_article(board_id): articles.append(i) if len(articles) == 0: return _('NO_NOTICE') return articles[random.randint(0, len(articles)-1)].aContent
def traverse_board_path(path, theme=None): if path == '^root': path = '/' ret = "" id = board._get_board_id_from_path(path) while id != 1 and id > 0: i = board.get_board_info(id) if i.bType == 0: if theme: ret = '/<a class="dirlink" href="/%s%s">%s</a>' % (theme, i.bName, i.bName.split('/')[-1]) + ret else: ret = '/<a class="dirlink" href="%s">%s</a>' % (i.bName, i.bName.split('/')[-1]) + ret else: if theme: ret = '/<a class="boardlink" href="/%s%s">%s</a>' % (theme, i.bName, i.bName.split('/')[-1]) + ret else: ret = '/<a class="boardlink" href="%s">%s</a>' % (i.bName, i.bName.split('/')[-1]) + ret new_id = board.get_parent(id) if new_id == id: break id = new_id # ret = (u'<a class="dirlink" href="/">%s</a>' % _('Board')) + ret return ret
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')