Beispiel #1
0
    def POST(self):
        flagid = self.env["members"][0]

        flag = fm.flagORM.getByID(flagid)

        if flag.userID != self.session.id:
            self.session.pushAlert("You can't delete a flag you don't own!", "Can't do that!", "error")

            self.head = ("303 SEE OTHER",
                [("location", "/you/flags")])

            return

        pubFlags = pubfc.userPublicFlagsCollection(self.session.id)
        privFlags = fc.userFlagsCollection(self.session.id)
        if flag.visibility:
            pubFlags.delObject(flag.id)
        privFlags.delObject(flag.id)

        flag.delete()

        su.updateSearch()

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

        self.head = ("303 SEE OTHER",
            [("location", "/you/flags")])
    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")])
Beispiel #3
0
    def POST(self):
        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"] if self.env["members"].has_key("labels") else ""
        url = self.env["members"]["url"] if self.env["members"].has_key("url") else ""
        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 = flagNewTmpl(searchList=[self.tmplSearchList])

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

            return view

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

        for label in range(len(labels)):
            labels[label] = mdu.cleanInput(labels[label])

        newFlag = fm.flagORM(title=mdu.cleanInput(title), description=description, labels=labels, url=url, userID=self.session.id, visibility=visibility)

        pubFlags = pubfc.userPublicFlagsCollection(self.session.id)
        privFlags = fc.userFlagsCollection(self.session.id)
        if visibility:
            pubFlags.addObject(newFlag.id)
        privFlags.addObject(newFlag.id)

        newFlag.save()

        su.updateSearch()

        self.session.pushAlert("Hey look, you've made another flag!", "Horay!", "success")

        self.head = ("303 SEE OTHER",
            [("location", str("/flags/view/%s"%newFlag.id))])
Beispiel #4
0
    def GET(self):
        """
        """
        page = self.env["members"]["p"] \
                if self.env["members"].has_key("p") else 1

        viewType = self.env["members"]["v"] \
                if self.env["members"].has_key("v") else "public"

        view = youFlagsTmpl(searchList=[self.tmplSearchList])

        if viewType == "public":
            flags = pubfc.userPublicFlagsCollection(self.session.id)
            flags.paginate(page, 25)
            flags.fetch()
            flags.format()

        elif viewType == "private":
            flags = fc.userFlagsCollection(self.session.id)
            flags.withoutCollection(pubfc.userPublicFlagsCollection(self.session.id))
            flags.paginate(page, 25)
            flags.fetch()
            flags.format()

        view.section = viewType

        if self.env["cfg"].enableModalFlagDeletes:
            view.scripts = ["handlebars_1.0.min",
                    "jquery.json-2.4.min",
                    "adminModal.flagr",
                    "editForm.flagr",
                    "deleteFlagModal.flagr"]

        flagsTmpl = flagsListTmpl(searchList=[self.tmplSearchList])
        flagsTmpl.flags = flags

        view.flags = str(flagsTmpl)

        return view