示例#1
0
文件: dashboard.py 项目: eth2net/june
    def post(self):
        o = ObjectDict()
        o.title = self.get_argument("title", None)
        o.slug = self.get_argument("slug", None)
        o.avatar = self.get_argument("avatar", None)
        o.description = self.get_argument("description", None)
        o.fgcolor = self.get_argument("fgcolor", None)
        o.bgcolor = self.get_argument("bgcolor", None)
        o.header = self.get_argument("header", None)
        o.sidebar = self.get_argument("sidebar", None)
        o.footer = self.get_argument("footer", None)
        try:
            o.limit_reputation = int(self.get_argument("reputation", 0))
        except:
            o.limit_reputation = 0

        try:
            o.limit_role = int(self.get_argument("role", 0))
        except:
            o.limit_role = 0

        if not (o.slug and o.title and o.description):
            self._context.message = "Please fill the required field"
            self.render("dashboard_node.html", node=o)
            return
        node = Node(**o)
        self.db.add(node)
        self.db.commit()
        self.redirect("/node/%s" % o.slug)