예제 #1
0
    def get(self, tags=""):

        cellar_id = None

        cellar = Cellar()
        res_web = cellar.GetWebCellar()

        if "success" in res_web:
            cellar_id = res_web["success"]

        page = int(self.get_argument("page", "1"))
        ajax = int(self.get_argument("ajax", 0))

        tags = tags.replace("_", " ").lower()

        tags_arr = tags.split(",")

        items = 0

        tallas = []

        tag = Tag()

        res = tag.GetItemsByTags(cellar_id, tags_arr)

        if "success" in res:
            items = int(res["success"])

        res = tag.GetProductsByTags(cellar_id, tags_arr, page, 16)

        tags_visibles = tag.ListVisibleTags(tags_arr)

        if "success" in tags_visibles:
            tags = tags_visibles["success"]

        product = Product()

        tallas_res = product.getAllSizes()

        if "success" in tallas_res:
            tallas = tallas_res["success"]

        if "success" in res:
            if ajax == 0:
                self.render("store/index.html",
                            data=res["success"],
                            items=items,
                            page=page,
                            tags=tags,
                            tags_arr=tags_arr,
                            tag=",".join(tags_arr),
                            tallas=tallas)
            else:
                self.render("store/ajax_productos.html",
                            data=res["success"],
                            items=items,
                            tag=",".join(tags_arr),
                            page=page)
        else:
            self.render("beauty_error.html", message=res["error"])