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')
def modify_post(self, board_name, board_id, article_id, current_uid = -1): if not acl.is_allowed('article', article_id, current_uid, 'modify'): return util.render().error(error_message = _('NO_PERMISSION'), help_context='error') data = web.input(new_attachment= {}) fs = web.ctx.get('_fieldstorage') try: if fs.has_key('delete'): to_delete = fs['delete'] if type(to_delete) == list: for f in to_delete: attachment.remove_attachment(article_id, f.value) else: try: attachment.remove_attachment(article_id, to_delete.value) except: pass if fs.has_key('new_attachment'): new_attachment = fs['new_attachment'] if type(new_attachment) == list: for f in new_attachment: attachment.add_attachment(article_id, f.filename, f.value) else: try: attachment.add_attachment(article_id, new_attachment.filename, new_attachment.value) except: pass except: pass mark_as_unreaded = web.input().has_key('unreaded') a = dict(title = data.title, body = data.content) board_info = board.get_board_info(board_id) ret = article.modify_article(current_uid, board_id, article_id, a, mark_as_unreaded) if ret[0] == True: raise web.seeother(util.link('/%s/+read/%s') % (board_name, ret[1])) else: return util.render().error(error_message = ret[1], help_context='error')
def reply_post(self, board_name, board_id, article_id, current_uid = -1): if not acl.is_allowed('board', board_id, current_uid, 'write'): return util.render().error(error_message = _('NO_PERMISSION'), help_context = 'error') reply = dict(title = web.input().title, body = web.input().content) board_info = board.get_board_info(board_id) ret = article.reply_article(current_uid, board_id, article_id, reply) if ret[0] == True: 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 raise web.seeother(util.link('/%s/+read/%s') % (board_name, ret[1])) else: return util.render().error(error_message = ret[1], help_context='error')