Ejemplo n.º 1
0
    def get(self):
        data = request.data
        user = request.user
        page, number = self.pageinfo

        params = filter_maybe(data, {"name": "name__contains"})
        ins = user.buckets.filter_by(**params).paginate(page, number)
        serializer = BucketSerializer(ins)
        return HTTP.OK(data=serializer.data)
Ejemplo n.º 2
0
 def get(self):
     data = request.data
     page, number = self.pageinfo
     params = filter_maybe(data, {"username": "******"})
     ins = User.query.filter_by(**params).paginate(page, number, False)
     rep = Serializer(
         ins,
         exclude=["articles", "buckets", "timelines"],
     ).data
     return HTTP.OK(data=rep, pageinfo=ins.pages)
Ejemplo n.º 3
0
    def get(self):
        request_data = request.data
        page, number = self.pageinfo
        kwargs = filter_maybe(
            request_data, {
                "tag": "tags__name",
                "category": "category__name",
                "title": "title__contains",
                "year": "created_at__year",
                "month": "created_at__month"
            })
        order_by = ("-created_at", )

        ins = Blog.query.filter_by(**kwargs).order_by(*order_by).paginate(
            page, number)
        return HTTP.HTML('blog/itemlist.html', blogs=ins)
Ejemplo n.º 4
0
    def get(self, bucket):
        data = request.data
        user = request.user
        page, number = self.pageinfo

        bucket = user.buckets.filter_by(
            name=bucket).get_or_404("bucket not found")
        path = request.data.get("path", "/")

        params = filter_maybe(data, {
            "name": "name__contains",
        })
        rootpath = bucket.get_root_path(path)
        paths = rootpath.child_paths.filter_by(**params).paginate(page, number)
        serializer = FilePathSerializer(paths)
        return HTTP.OK(data=serializer.data)
Ejemplo n.º 5
0
    def get(self):
        data = request.data
        page, number = self.pageinfo
        params = filter_maybe(
            data, {
                "tag": "tags__name",
                "category": "category__name",
                "title": "title__contains",
                "year": "created_at__year",
                "month": "created_at__month"
            })
        order_by = ("-created_at", )

        ins = Article.query.filter_by(**params).order_by(*order_by).paginate(
            page, number)
        return HTTP.HTML('articles.html', articles=ins)
Ejemplo n.º 6
0
    def get(self):
        request_data = request.data
        kwargs = filter_maybe(
            request_data, {
                "tag": "tags__name",
                "category": "category__name",
                "title": "title__contains",
                "year": "created_at__year",
                "month": "created_at__month"
            })
        order_by = ("-created_at", )

        ins = OrderedDict()
        for blog in Blog.query.filter_by(**kwargs).order_by(*order_by):
            date = blog.created_at.strftime("%Y年%m月")
            ins.setdefault(date, [])
            ins[date].append(blog)
        return HTTP.HTML('blog/archives.html', blogs=ins)
Ejemplo n.º 7
0
 def get(self, year=None, month=None):
     data = request.data
     params = filter_maybe(
         data, {
             "tag": "tags__name",
             "category": "category__name",
             "title": "title__contains",
             "year": "created_at__year",
             "month": "created_at__month"
         })
     if year:
         params.update(created_at__year=year)
     if month:
         params.update(created_at__month=month)
     order_by = ("-created_at", )
     ins = OrderedDict()
     for article in Article.query.filter_by(**params).order_by(*order_by):
         date = article.created_at.strftime("%Y年%m月")
         ins.setdefault(date, [])
         ins[date].append(article)
     return HTTP.HTML('archives.html', articles=ins)