Exemplo n.º 1
0
    def GET(self):
        search_term = self.request.get_param("s")

        all_tags = r.table(nm.Note.table)\
            .concat_map(lambda doc: doc["tags"])\
            .distinct()\
            .coerce_to('array').run()

        self.view.data = {"tags": all_tags, "note_page": None}

        search_term = self.request.get_param("s")
        if search_term:
            search_term = search_term.replace("tag:", "tags:")

            searcher = NoteSearcher()
            parts = {"disable": False, "public": True, "draft": False}

            ids = searcher.search(search_term, collection=True)
            if ids is not None:
                ids.filter(parts)
                ids.fetch()

                page = Paginate(ids,
                                self.request,
                                "created",
                                sort_direction_default="asc")
                self.view.data = {"note_page": page}

            self.view.template = "public/notes/search/results"

        return self.view
Exemplo n.º 2
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar", {"command": "recipes"})

        deleted = self.request.get_param("d", False)
        reported = self.request.get_param("r", False)
        public = self.request.get_param("p", False)
        search = self.request.get_param("s")

        if not search:
            parts = {}

            if deleted:
                parts["deleted"] = True

            if reported:
                parts["reported"] = True

            if public:
                parts["public"] = True

            query = r.table(rm.Recipe.table).filter(parts)
            res = RethinkCollection(rm.Recipe, query=query)

        else:
            pass

        page = Paginate(res, self.request, "title", sort_direction_default="desc")

        return {"recipes": page}
Exemplo n.º 3
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "users"})
        try:
            user = um.User(self.request.id)

        except NotFoundError:
            return NotFound()

        self.view.title = user.username

        disabled = self.request.get_param("q")
        hidden_ids = r.table(pm.Phot.table).filter({
            "user": user.id
        }).filter(r.row["disable"].eq(True)).concat_map(
            lambda doc: [doc["id"]]).coerce_to("array").run()

        if disabled == "enabled":
            query = r.table(pm.Phot.table).filter({
                "user": user.id
            }).filter(lambda doc: ~r.expr(hidden_ids).contains(doc["id"]))

        else:
            query = r.table(pm.Phot.table).filter({
                "user": user.id
            }).filter(lambda doc: r.expr(hidden_ids).contains(doc["id"]))

        res = RethinkCollection(pm.Phot, query=query)

        page = Paginate(res, self.request, "created")

        self.view.data = {"page": page, "user": user, "command": "phots"}

        return self.view
Exemplo n.º 4
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "phots"})
        what = self.request.get_param("v")
        orig = self.request.get_param("filter", "all")
        filt = dbu.phot_filter(orig)

        hidden_ids = list(
            r.table(pm.Phot.table).filter(r.row["disable"].eq(
                True)).concat_map(lambda doc: [doc["id"]]).run())

        if what == "enabled":
            query = r.table(pm.Phot.table).filter(
                lambda doc: ~r.expr(hidden_ids).contains(doc["id"]))

        else:
            query = r.table(pm.Phot.table).filter(
                lambda doc: r.expr(hidden_ids).contains(doc["id"]))

        query = query.filter(lambda doc: doc["filename"].match(filt))

        result = RethinkCollection(pm.Phot, query=query)
        page = Paginate(result, self.request, "filename")

        self.view.data = {"page": page}
        self.view.scripts = ["transientbug/admin/phot"]

        return self.view
Exemplo n.º 5
0
    def GET(self):
        filter_parts = {}
        public = self.request.get_param("public")
        draft = self.request.get_param("draft")
        reported = self.request.get_param("reported", False)
        sort_by = self.request.get_param("sort_by", "created", "asc")

        if not sort_by in [
                "created", "title", "public", "reported", "draft", "author.id"
        ]:
            sort_by = "created"

            # should this be something I try to start doing? :/
            self.session.push_alert(
                "Couldn't figure out what to sort by, as a result of an invalid value for sort_by.",
                level="error")

        if public:
            filter_parts["public"] = False if public == "private" else True
        if draft:
            filter_parts["draft"] = False if draft == "published" else True

        filter_parts["disable"] = False
        filter_parts["reported"] = reported

        q = r.table(nm.Note.table).filter(filter_parts)

        res = RethinkCollection(nm.Note, query=q)
        page = Paginate(res, self.request, sort_by)

        self.view.data = {"note_page": page}

        return self.view
Exemplo n.º 6
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar", {"command": "users"})
        try:
            user = um.User(self.request.id)

        except NotFoundError:
            return NotFound()

        self.view.title = user.username

        t = self.request.get_param("filter", "to")
        if t == "cc":
            row_filt = "cc_addresses"
        elif t == "bcc":
            row_filt = "bcc_addresses"
        else:
            row_filt = "to_addresses"

        parts = r.table(em.Email.table).filter(lambda row: row[row_filt].contains(user.id))

        result = RethinkCollection(em.Email, query=parts)
        page = Paginate(result, self.request, "created", sort_direction_default="asc")

        self.view.data = {"page": page,
                          "user": user,
                          "command": "emails"}

        return self.view
Exemplo n.º 7
0
    def GET(self):
        search_term = self.request.get_param("s")
        if search_term:
            search_term = search_term.replace("tag:", "tags:")

            searcher = NoteSearcher()
            hidden_notes = {
                "disable": False,
                "reported": False,
                "public": True,
                "draft": False
            }
            ids = searcher.search(search_term,
                                  collection=True,
                                  pre_filter=hidden_notes)

            if ids is not None:
                ids.fetch()

                page = Paginate(ids,
                                self.request,
                                "title",
                                sort_direction_default="desc")
                return page

            return {"page": None, "pail": None}

        return {"error": "No search (s) term provided."}
Exemplo n.º 8
0
    def GET(self):
        search_term = self.request.get_param("s")
        if search_term:
            search_term = search_term.replace("tag:", "tags:")

            searcher = PhotSearcher()
            phots_hidden_filter = dbu.rql_where_not(pm.Phot.table,
                                                    "disable",
                                                    True,
                                                    raw=True)
            ids = searcher.search(search_term,
                                  collection=True,
                                  pre_filter=phots_hidden_filter)

            if ids is not None:
                ids.fetch()

                page = Paginate(ids,
                                self.request,
                                "title",
                                sort_direction_default="desc")
                return page

            return {"page": None, "pail": None}

        return {"error": "No search (s) term provided."}
Exemplo n.º 9
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "users"})
        try:
            user = um.User(self.request.id)

        except NotFoundError:
            return NotFound()

        self.view.title = user.username

        deleted = self.request.get_param("d", False)
        reported = self.request.get_param("r", False)

        parts = {"user": user.id}

        if deleted:
            parts["deleted"] = True

        if reported:
            parts["reported"] = True

        query = r.table(rm.Recipe.table).filter(parts)
        res = RethinkCollection(rm.Recipe, query=query)
        page = Paginate(res,
                        self.request,
                        "title",
                        sort_direction_default="desc")

        return {"recipes": page, "user": user, "command": "recipes"}
Exemplo n.º 10
0
    def GET(self):
        search_term = self.request.get_param("s")

        all_tags = r.table(rm.Recipe.table)\
            .concat_map(lambda doc: doc["tags"])\
            .distinct()\
            .coerce_to('array').run()

        self.view.data = {"tags": all_tags, "recipes": None}

        if search_term:
            if "recipe:" in search_term:
                parts = search_term.split(" ")
                for part in parts:
                    if "recipe:" in part:
                        recipe = rm.Recipe.find(part[7:])

                        if recipe is not None:
                            return Redirect("/recipes/{}".format(part[7:]))

            search_term = search_term.replace("tag:", "tags:")

            searcher = RecipeSearcher()

            if self.session.id:
                allow = q.Or([
                    q.And([
                        q.Term("user", self.session.id),
                        q.Term("deleted", False),
                        q.Term("reported", False)
                    ]),
                    q.And([
                        q.Term("public", True),
                        q.Term("deleted", False),
                        q.Term("reported", False)
                    ])
                ])

            else:
                allow = q.And([
                    q.Term("public", True),
                    q.Term("deleted", False),
                    q.Term("reported", False)
                ])

            ids = searcher.search(search_term, collection=True, allow=allow)
            if ids is not None:
                ids.fetch()

                page = Paginate(ids,
                                self.request,
                                "title",
                                sort_direction_default="desc")
                self.view.data = {"recipes": page}

            self.view.template = "public/recipes/search/results"

        return self.view
Exemplo n.º 11
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "emails"})

        result = RethinkCollection(em.Email)
        page = Paginate(result, self.request, "created")

        self.view.data = {"page": page}

        return self.view
Exemplo n.º 12
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "announcements"})
        announcements = am.all_announcements()

        page = Paginate(announcements, self.request, "created")

        self.view.data = {"page": page}

        return self.view
Exemplo n.º 13
0
    def GET(self):
        f = []
        for top, folders, files in os.walk(c.dirs.screenshots):
            f.extend(files)
            break

        page = Paginate(f, self.request, sort_direction_default="asc")

        self.view.data = {"page": page}
        return self.view
Exemplo n.º 14
0
    def GET(self):
        orig = self.request.get_param("filter", "all")
        filt = dbu.phot_filter(orig)

        query = dbu.rql_where_not(pm.Phot.table, "disable", True)
        query = query.filter(lambda doc: doc["filename"].match(filt))
        res = RethinkCollection(pm.Phot, query=query)

        page = Paginate(res, self.request, "title")

        return page
Exemplo n.º 15
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "invites"})

        res = RethinkCollection(im.Invite)
        page = Paginate(res,
                        self.request,
                        "created",
                        sort_direction_default="asc")

        self.view.data = {"page": page}

        return self.view
Exemplo n.º 16
0
    def GET(self):
        parts = r.table(rm.Recipe.table).filter({
            "deleted": False,
            "public": True,
            "reported": False
        })

        result = RethinkCollection(rm.Recipe, query=parts)
        page = Paginate(result,
                        self.request,
                        "title",
                        sort_direction_default="desc")

        return {"recipes": page}
Exemplo n.º 17
0
    def GET(self):
        query = r.table(rm.Recipe.table).filter({
            "deleted": False,
            "reported": False,
            "public": True
        })

        res = RethinkCollection(rm.Recipe, query=query)

        page = Paginate(res,
                        self.request,
                        "name",
                        sort_direction_default="desc")

        return page
Exemplo n.º 18
0
    def GET(self):
        parts = r.table(nm.Note.table).filter({
            "disable": False,
            "public": True,
            "draft": False
        })

        result = RethinkCollection(nm.Note, query=parts)
        page = Paginate(result,
                        self.request,
                        "created",
                        sort_direction_default="asc")

        self.view.data = {"note_page": page}

        return self.view
Exemplo n.º 19
0
    def GET(self):
        query = r.table(nm.Note.table).filter({
            "disable": False,
            "reported": False,
            "public": True,
            "draft": False
        })

        res = RethinkCollection(nm.Note, query=query)

        page = Paginate(res,
                        self.request,
                        "created",
                        sort_direction_default="asc")

        return page
Exemplo n.º 20
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "users"})
        disabled = self.request.get_param("d", True)
        if disabled:
            q = dbu.rql_where_not(um.User.table, "disable", True)
            res = RethinkCollection(um.User, query=q)

        else:
            res = RethinkCollection(um.User)

        page = Paginate(res, self.request, "username")

        self.view.data = {"page": page}

        return self.view
Exemplo n.º 21
0
    def GET(self):
        self.view.partial("sidebar", "partials/admin/sidebar",
                          {"command": "users"})
        try:
            user = um.User(self.request.id)

        except NotFoundError:
            return NotFound()

        self.view.title = user.username

        # I should figure out a way to do this filter stuff a little easier... hmm
        filter_parts = {"user": user.id}
        public = self.request.get_param("public")
        draft = self.request.get_param("draft")
        disabled = self.request.get_param("disable")
        reported = self.request.get_param("reported", False)
        sort_by = self.request.get_param("sort_by", "created")

        if not sort_by in [
                "created", "title", "public", "reported", "draft", "disable",
                "author.id"
        ]:
            sort_by = "created"

            # should this be something I try to start doing? :/
            self.session.push_alert(
                "Couldn't figure out what to sort by, as a result of an invalid value for sort_by.",
                level="error")

        if public:
            filter_parts["public"] = False if public == "private" else True
        if draft:
            filter_parts["draft"] = False if draft == "published" else True
        if disabled:
            filter_parts["disable"] = False if disabled == "enabled" else True

        filter_parts["reported"] = reported

        q = r.table(nm.Note.table).filter(filter_parts)

        res = RethinkCollection(nm.Note, query=q)
        page = Paginate(res, self.request, sort_by)

        self.view.data = {"note_page": page, "user": user, "command": "notes"}

        return self.view
Exemplo n.º 22
0
    def GET(self):
        view = self.request.get_param("v")
        q = dbu.rql_where_not(pm.Phot.table, "disable", True)

        all_tags = q\
            .concat_map(lambda doc: doc["tags"])\
            .distinct()\
            .coerce_to('array').run()

        if "phot_view" in self.session.data:
            if not view:
                view = self.session.data.phot_view
        else:
            self.session.data.phot_view = "cards"
            view = "cards"

        self.session.data.phot_view = view

        self.view.data = {
            "tags": all_tags,
            "phot_page": None
        }

        search_term = self.request.get_param("s")
        if search_term:
            search_term = search_term.replace("tag:", "tags:")

            searcher = PhotSearcher()
            phots_hidden_filter = dbu.rql_where_not(pm.Phot.table, "disable", True, raw=True)
            ids = searcher.search(search_term, collection=True, pre_filter=phots_hidden_filter)

            if ids is not None:
                ids.fetch()

                page = Paginate(ids, self.request, "title", sort_direction_default="desc")
                self.view.data = {"phot_page": page, "v": view}

            self.view.template = "public/phots/search/results"

        return self.view
Exemplo n.º 23
0
    def GET(self):
        search_term = self.request.get_param("s")
        if search_term:
            search_term = search_term.replace("tag:", "tags:")

            searcher = RecipeSearcher()

            if self.session.id:
                allow = q.Or([
                    q.And([
                        q.Term("user", self.session.id),
                        q.Term("deleted", False),
                        q.Term("reported", False)
                    ]),
                    q.And([
                        q.Term("public", True),
                        q.Term("deleted", False),
                        q.Term("reported", False)
                    ])
                ])

            else:
                allow = q.And([
                    q.Term("public", True),
                    q.Term("deleted", False),
                    q.Term("reported", False)
                ])

            ids = searcher.search(search_term, collection=True, allow=allow)

            if ids is not None:
                page = Paginate(ids,
                                self.request,
                                "title",
                                sort_direction_default="desc")
                return page

        return {"page": None, "pail": None}
Exemplo n.º 24
0
    def GET(self):
        user = um.User(self.session.id)

        t = self.request.get_param("filter", "to")
        if t == "cc":
            row_filt = "cc_addresses"
        elif t == "bcc":
            row_filt = "bcc_addresses"
        else:
            row_filt = "to_addresses"

        parts = r.table(
            em.Email.table).filter(lambda row: row[row_filt].contains(user.id))

        result = RethinkCollection(em.Email, query=parts)
        page = Paginate(result,
                        self.request,
                        "created",
                        sort_direction_default="asc")

        self.view.data = {"user": user, "page": page, "command": "emails"}

        return self.view
Exemplo n.º 25
0
    def GET(self):
        d = self.request.get_param("d")
        p = self.request.get_param("p")
        parts = {"deleted": False, "user": self.session.id}

        if d:
            parts["deleted"] = True

        if not ("public" in p and "private" in p):
            if "public" in p:
                parts["public"] = True

            elif "private" in p:
                parts["public"] = False

        parts = r.table(rm.Recipe.table).filter(parts)

        result = RethinkCollection(rm.Recipe, query=parts)
        page = Paginate(result,
                        self.request,
                        "title",
                        sort_direction_default="desc")

        return {"recipes": page}
Exemplo n.º 26
0
 def GET(self):
     self.view.partial("sidebar", "partials/admin/sidebar",
                       {"command": "buckets"})
     page = Paginate(self.buckets.list, self.request)
     self.view.data = {"page": page}
     return self.view