Esempio n. 1
0
    def GET(self):
        """
        """
        flagid = self.env["members"][0]

        flag = flagORM.getByID(flagid)
        view = adminDelFlagTmpl(searchList=[self.tmplSearchList])

        view.flag = flag

        return view
    def POST(self):
        flagid = self.env["members"][0]
        title = self.env["members"]["title"] if self.env["members"].has_key("title") else None
        description = self.env["members"]["description"] or ""
        labels = self.env["members"]["labels"] or ""
        url = self.env["members"]["url"] or ""
        visibility = True if self.env["members"].has_key("vis") and self.env["members"]["vis"] == "on" else False

        if not title:
            self.session.pushAlert("We can't make a flag with no title!", "Whoa there kiddo...", "error")
            view = adminEditFlagTmpl(searchList=[self.tmplSearchList])

            view.titleError = True
            view.description = description
            view.labels = labels
            view.url = url
            view.id = flagid
            view.vis = visibility

            return view

        try:
            labels = list(set(json.loads(labels)))
        except:
            labels = list(set(labels.strip(" ").split(",")))

        flag = flagORM.getByID(flagid)
        flag.title = title
        flag.description = description
        flag.labels = labels
        flag.url = url

        if flag.visibility != visibility:
            pubFlags = pubfc.userPublicFlagsCollection(flag.userID)
            if visibility:
                pubFlags.addObject(flag.id)
            else:
                pubFlags.delObject(flag.id)

            flag.visibility = visibility

        flag.save()


        self.session.pushAlert("Flag `%s` updated" % flag.title, "Yay", "success")

        self.head = ("303 SEE OTHER",
            [("location", "/admin/flags")])
Esempio n. 3
0
    def POST(self):
        flagid = self.env["members"][0]

        flag = flagORM.getByID(flagid)
        pubFlags = pubfc.userPublicFlagsCollection(flag.userID)
        privFlags = fc.userFlagsCollection(flag.userID)
        if flag.visibility:
            pubFlags.delObject(flag.id)
        privFlags.delObject(flag.id)

        flag.delete()

        self.session.pushAlert("Flag `%s` deleted" % flag.title, "Bye!", "warning")

        self.head = ("303 SEE OTHER",
            [("location", "/admin/flags")])
    def GET(self):
        """
        """
        flagid = self.env["members"][0]

        flag = flagORM.getByID(flagid)
        view = adminEditFlagTmpl(searchList=[self.tmplSearchList])

        view.id = flagid

        view.title = flag.title
        view.description = flag.description
        view.url = flag.url
        view.vis = flag.visibility

        if self.env["cfg"].enableDynamicLabels:
            view.scripts = ["handlebars_1.0.min",
                    "jquery.json-2.4.min",
                    "dynamicInput.flagr"]
            view.labels = json.dumps(flag.labels)
        else:
            view.labels = flag.labels.join(", ")

        return view