예제 #1
0
    def get_picture(self, instance):
        picture = ""
        b = instance

        if b.picture:
            picture = get_upload_host(self.context["request"]) + b.picture.url

        return picture
예제 #2
0
    def get_picture(self, instance):
        picture = ""
        category = instance

        if category.picture:
            picture = get_upload_host(
                self.context["request"]) + category.picture1.url
        return picture
예제 #3
0
    def get_cart_items(self, instance):
        items = []
        cart_items = CartItem.objects.filter(cart=instance, is_archived=False)
        for i in cart_items:
            item_product_pictures = []
            if i.variety.picture1:
                item_product_pictures.append(
                    get_upload_host(self.context["request"]) +
                    i.variety.picture1.url)
            if i.variety.picture2:
                item_product_pictures.append(
                    get_upload_host(self.context["request"]) +
                    i.variety.picture2.url)
            if i.variety.picture3:
                item_product_pictures.append(
                    get_upload_host(self.context["request"]) +
                    i.variety.picture3.url)
            if i.variety.picture4:
                item_product_pictures.append(
                    get_upload_host(self.context["request"]) +
                    i.variety.picture4.url)

            item = {
                "id":
                i.id,
                "slug":
                i.variety.product.slug,
                "title":
                "%s - %s" % (i.variety.product.title, i.variety.color.title),
                "description":
                i.variety.product.description,
                "price":
                i.variety.product.price,
                "color":
                i.variety.color.title,
                "size":
                i.variety.size.name,
                "selected_quantity":
                i.quantity,
                "line_total": (i.variety.product.price * i.quantity),
                "pictures":
                item_product_pictures
            }
            items.append(item)
        return items
예제 #4
0
    def get_articleImage(self, instance):
        picture = ""
        b = instance

        if b.articleImage:
            picture = get_upload_host(
                self.context["request"]) + b.articleImage.url

        return picture
예제 #5
0
    def get_pictures(self, instance):
        """
        Get at max 30 pictures for all services composing this pack
        """
        pics = []
        # si le queryset services_of_pack est grand
        v = Variety.objects.filter(product=instance).first()

        if v is not None:
            if v.picture1:
                pics.append(get_upload_host(self.context["request"]) + v.picture1.url)
            if v.picture2:
                pics.append(get_upload_host(self.context["request"]) + v.picture2.url)
            if v.picture3:
                pics.append(get_upload_host(self.context["request"]) + v.picture3.url)
            if v.picture4:
                pics.append(get_upload_host(self.context["request"]) + v.picture4.url)

        return pics
예제 #6
0
    def get_pictures(self, instance):
        pictures = []
        variety = instance
        if variety.picture1:
            pictures.append(
                get_upload_host(self.context["request"]) +
                variety.picture1.url)
        if variety.picture2:
            pictures.append(
                get_upload_host(self.context["request"]) +
                variety.picture2.url)
        if variety.picture3:
            pictures.append(
                get_upload_host(self.context["request"]) +
                variety.picture3.url)
        if variety.picture4:
            pictures.append(
                get_upload_host(self.context["request"]) +
                variety.picture4.url)

        # if category.picture:
        #     picture = get_upload_host(self.context["request"]) + category.picture1.url
        return pictures
예제 #7
0
 def get_product_url(self, instance):
     product_url = get_upload_host(
         self.context["request"]) + instance.get_absolute_url()
     return product_url