Exemple #1
0
    def get(self, request, *args, **kwargs):
        product = self.object = self.get_object()

        if product.mode == ProductMode.VARIATION_CHILD:
            # redirect to parent url with child pre-selected
            parent_url = reverse("shuup:product",
                                 kwargs=dict(
                                     pk=product.variation_parent.pk,
                                     slug=product.variation_parent.slug))
            return HttpResponseRedirect("{}?variation={}".format(
                parent_url, product.sku))

        try:
            shop_product = self.shop_product = product.get_shop_instance(
                request.shop, allow_cache=True)
        except ShopProduct.DoesNotExist:
            raise Problem(_(u"This product is not available in this shop."))

        errors = list(
            shop_product.get_visibility_errors(customer=request.customer))

        if errors:
            raise Problem("\n".join(extract_messages(errors)))

        return super(ProductDetailView, self).get(request, *args, **kwargs)
Exemple #2
0
    def get(self, request, *args, **kwargs):
        product = self.object = self.get_object()

        if product.mode == ProductMode.VARIATION_CHILD:
            return redirect("shuup:product", pk=product.variation_parent.pk, slug=product.variation_parent.slug)

        shop_product = self.shop_product = product.get_shop_instance(request.shop)
        if not shop_product:
            raise Problem(_(u"This product is not available in this shop."))

        errors = list(shop_product.get_visibility_errors(customer=request.customer))

        if errors:
            raise Problem("\n".join(extract_messages(errors)))

        return super(ProductDetailView, self).get(request, *args, **kwargs)
Exemple #3
0
    def get(self, request, *args, **kwargs):
        product = self.object = self.get_object()

        if product.mode == ProductMode.VARIATION_CHILD:
            return redirect("shuup:product", pk=product.variation_parent.pk, slug=product.variation_parent.slug)

        try:
            shop_product = self.shop_product = product.get_shop_instance(request.shop, allow_cache=True)
        except ShopProduct.DoesNotExist:
            raise Problem(_(u"This product is not available in this shop."))

        errors = list(shop_product.get_visibility_errors(customer=request.customer))

        if errors:
            raise Problem("\n".join(extract_messages(errors)))

        return super(ProductDetailView, self).get(request, *args, **kwargs)