示例#1
0
文件: board.py 项目: sbkkt/words
    def post(self):
        words = self.get_argument('words', '')  # 用户的留言
        find_words = self.get_argument('find_words', '')  # 模糊查询的字符串
        dele_by_id = self.get_argument('dele_by_id', '')
        words_query = Board.get_all()  # 获取所有留言
        IP = self.request.remote_ip
        # history_time = time.strftime('%Y-%m-%d %X', time.localtime()) #获取当前时间,与用户留言一起存入数据库
        # user_key = self.get_secure_cookie('u')
        # User.get_by_key(user_key) #凭key找到当前用户

        user = self.current_user()
        if find_words:  # 模糊查询
            find_words_query = Board.get_by_words(find_words)
            self.messages.success("查询成功!")
        else:
            find_words_query = []
        if words:
            username = user.username
            Board.new(username, words, IP)
            self.messages.success("留言成功!")
        if dele_by_id:
            if user.is_admin():  # 如果不是admin用户将无法删除
                Board.dele_by_id(dele_by_id)
                self.messages.success("删除成功!")
            else:
                self.messages.error("您没有删除权限!")

        self.render(
            'board.html',
            words_query=words_query,
            find_words_query=find_words_query,
        )
示例#2
0
文件: board.py 项目: jtwmyddsgx/1024
    def post(self):
        words = self.get_argument('words', '')  # 用户的留言
        dele_by_key = self.get_argument('theKey', '')
        IP = self.request.headers["X-Forwarded-For"]
        user = self.current_user()
        username = None
        word_user = None
        word_username = None
        if user is None:
            user = JsDict()
            user.username = "******"

        if dele_by_key != "":
            word_user = Board.get_one(Board.key == dele_by_key)
        if word_user is not None:
            word_username = word_user.username
        if user is not None:
            username = user.username
        if dele_by_key:
            if user.is_admin() or username == word_username:  # 如果不是admin用户将无法删除
                Board.dele_by_key(dele_by_key)
                self.write("删除成功!")
            else:
                self.write("您没有删除权限!")
        elif words:
            username = user.username
            user_re = re.compile(r"@(\S{3,19}) (.*)")
            try:
                foruser = user_re.search(words).group(1)
                if not User.exist(foruser):
                    foruser = ""
                else:
                    words = user_re.search(words).group(2)
            except Exception as e:
                foruser = ""
            if Board.num_lim(username):
                self.messages.error("留言过多,请联系管理员!")
                self.redirect("/board")
            elif user.username != "游客" and user.level == 0:
                self.messages.error("您暂时无法留言!")
                self.redirect(url_for("board"))
            else:
                Board.new(username, foruser, words, IP)
                self.messages.success("留言成功!")
                self.redirect(url_for("board"))
        else:
            self.redirect(url_for("board"))

        '''
示例#3
0
文件: board.py 项目: fy0/Icarus
 def post(self):
     title = self.get_argument('board_title', '').strip()
     brief = self.get_argument('board_brief', None)
     if not title:
         self.messages.error('必须填写板块名')
     else:
         if brief:
             brief = brief.strip()
         if not MBoard.new(title, self.current_user(), brief):
             self.messages.error('创建失败,是否有同名板块存在?')
     #self.set_header('Location', self.request.headers.get("Referer"))
     self.redirect(url_for('admin_forum_board'))
示例#4
0
文件: models.py 项目: fy0/Icarus
def first_run():
    if User.count() == 0:
        u = User.new('root', '123')
        Board.new('初学者', u, '你们啊,还是需要学习一个。')
        Board.new('问与答', u, '但是你们问来问去的问题呀,都 too young, too simple.')
        Board.new('游戏开发', u, '游戏制作的种种')
        Board.new('WEB开发', u, '当下最热门的技术种类')
        Board.new('发起项目', u, '已有创意,就差一个程序员/设计师/策划/运营了!')
        Board.new('项目展示', u, '今天我作为一个长者,给你们分享一点人生的经验')
        Board.new('水区', u, '社区的哪一个牛人我没有见过?我跟他们谈笑风生!')