Example #1
0
    def post(self):
        node_name = self.get_argument("node_name")
        node_desc = self.get_argument("node_desc")
        node_title = self.get_argument("node_title", "")
        node_help = self.get_argument("node_help", "")

        action = self.get_argument("action")
        if action == "edit":
            nid = self.get_argument("id")
            node = BoardNode.objects.with_id(nid)
            if node is None:
                return about(404)
            node.name = node_name
            node.title = node_title
            node.desc = node_desc

            helps = node_help.split("\n")
            help_list = []
            for help in helps:
                help = help.strip()
                if help:
                    help_list.append(help)
            node.help = help_list
            node.save()
            fetch_cached_board_nodelist(reflush=True)

            return self.redirect("/admin/board/node")

        elif action == "create":
            node = BoardNode()
            node.name = node_name
            node.desc = node_desc
            node.title = node_title
            helps = node_help.split("\n")
            help_list = []
            for help in helps:
                help = help.strip()
                if help:
                    help_list.append(help)
            node.help = help_list
            fetch_cached_board_nodelist(reflush=True)
            node.save()
            return self.redirect("/admin/board/node")