def GET(self):
                """
                """
                id = self.members[0]
                user = am.baseUser(id)

                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Edit User " + user.username
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                editForm = bf.baseForm(fields=[{
                        "name": "username",
                        "value": user["username"]
                        }, {
                        "name": "password",
                        "type": "password",
                        "placeholder": "New Password"
                        }, {
                        "name": "notes",
                        "type": "textarea",
                        "value": user["notes"]
                        }, {
                        "name": "submit",
                        "type": "submit",
                        "value": "Update"
                        }], action=("/admin/users/edit/" + id))

                view["content"] = bv.baseRow(editForm, offset=0)

                return view.build()
        def GET(self):
                """
                """
                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Adding a new Post"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                editForm = bf.baseForm(fields=[{
                        "name": "title",
                        }, {
                        "name": "post",
                        "type": "textarea"
                        }, {
                        "name": "submit",
                        "type": "submit",
                        "value": "Create"
                        }], action="/admin/posts/new")

                view["content"] = bv.baseRow(editForm, offset=0)

                return view.build()
        def GET(self):
                """

                """
                users = am.userList()

                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Users"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                pageHead = """What to <a href="%s">add a user?</a>""" % ("/admin/users/new")

                if users:
                        userList = bl.baseList(users, "row_list_User")

                        content = bv.baseRow(userList, 8, 0)

                else:
                        content = "Well either all of your users have god perms and aren't shown, or you don't have any additional users!"

                view["content"] = bv.baseRow([pageHead, content], 8, 0)

                return view.build()
        def GET(self):
                """
                """
                id = self.members[0]

                post = pm.basePost(id)

                editForm = bf.baseForm(fields=[{
                        "name": "title",
                        "value": post["title"]
                        }, {
                        "name": "post",
                        "value": post["post"],
                        "type": "textarea"
                        }, {
                        "name": "submit",
                        "type": "submit",
                        "value": "Update"
                        }], action=("/admin/posts/edit/" + id))

                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Edit Post" + id
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                view["content"] = bv.baseRow(editForm, offset=0)

                return view.build()
        def GET(self):
                """
                """
                posts = pm.postList()

                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Posts"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                pageHead = """Want to <a href="%s">add another post?</a>""" % ("/admin/posts/new")

                if posts:
                        postList = bl.baseList(posts, "row_list_Post")

                        content = bv.baseRow(postList, 8, 0)

                else:
                        content = "You don't have any posts at this time!"

                view["content"] = bv.baseRow([pageHead, content], 8, 0)

                return view.build()
        def GET(self):
                """
                This gives a nice little list of all the users in the system, 
                with the exception of users marked as having GOD level.
                """
                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Adding a new User"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                editForm = bf.baseForm(fields=[{
                        "name": "username",
                        "placeholder": "Username"
                        }, {
                        "name": "password",
                        "type": "password",
                        "placeholder": "Password"
                        }, {
                        "name": "notes",
                        "type": "textarea"
                        }, {
                        "name": "submit",
                        "type": "submit",
                        "value": "Update"
                        }], action="/admin/users/new")

                view["content"] = bv.baseRow(editForm, offset=0)

                return view.build()
        def GET(self):
                """
                Display the login page.
                """
                if c.session.loggedIn == True:
                        self.head = ("303 SEE OTHER", [("location", "/")])
                        c.session.pushMessage("Hey look, you're already signed in!")

                else:
                        view = bv.noSidebarView()

                        elements = be.baseElements()
                        view["nav"] = elements.navbar()

                        view["title"] = "Login"
                        view["messages"] = bv.baseRow(c.session.getMessages())

                        loginForm = bf.baseForm(fields=[{
                                "name": "username",
                                "placeholder": "Username",
                                }, {
                                "type": "password",
                                "name": "password",
                                "placeholder": "Password",
                                }, {
                                "type": "submit",
                                "name": "submit",
                                "value": "Login"
                                }], action=("/auth/login"), width=4)

                        view["content"] = bv.baseRow(loginForm, 4, 4)

                        return view.build()
Beispiel #8
0
        def GET(self):
                """

                """
                posts = pm.postList()

                view = bv.noSidebarView()

                elements = be.baseElements()
                view["nav"] = elements.navbar()

                view["title"] = "Home"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)


                postList = bl.baseList(posts, "post_index")

                view["content"] = bv.baseRow(postList)

                return view.build()
        def build(self):
                returnData = ""

                for block in self.blocks:
                        page = tc.partialTplSet[self.template]

                        for part in block.parts:
                                if type(block[part]) != str and block[part] != None:
                                        setattr(page, part, block[part].build())
                                else:
                                        setattr(page, part, block[part])

                        returnData += bv.baseRow(str(page), self.width, 0).build()

                return returnData
        def GET(self):
                """
                """
                view = bv.sidebarView()

                elements = be.adminElements()
                view["nav"] = elements.navbar()
                view["sidebar"] = elements.sidebar()

                view["title"] = "Admin Panel"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                view["content"] = "Well you have nothing to do here, but you might want to take a look over at the sidebar for somethings to do..."

                return view.build()
        def GET(self):
                """
                """
                user = am.baseUser()
                user["username"] = "******"
                user["level"] = "GOD"
                user["notes"] = ""
                user.password = "******"

                user.commit()

                print user.password, bcrypt.hashpw("josh", user.password)

                view = bv.noSidebarView()

                elements = be.baseElements()
                view["nav"] = elements.navbar()

                view["title"] = "Initial Setup"
                view["messages"] = bv.baseRow(c.session.getMessages(), 12, 0)

                view["content"] = "User Josh with password josh has been created."

                return view.build()