Пример #1
0
    def clean(self):
        form_pre_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=self.cleaned_data)
        data = super(ShopProductForm, self).clean()
        if not getattr(settings, "SHUUP_AUTO_SHOP_PRODUCT_CATEGORIES", False):
            return data

        # handle this here since form_part save causes problems with signals
        primary_category = data.get("primary_category")
        categories = data.get("categories", []) or []
        if categories:
            categories = list(categories)

        if not primary_category and categories:
            primary_category = categories[0]  # first is going to be primary

        if primary_category and primary_category not in categories:
            combined = [primary_category] + categories
            categories = combined

        data["primary_category"] = primary_category
        data["categories"] = categories

        form_post_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=data)
        return data
Пример #2
0
    def clean(self):
        form_pre_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=self.cleaned_data)
        data = super(ShopProductForm, self).clean()
        if not getattr(settings, "SHUUP_AUTO_SHOP_PRODUCT_CATEGORIES", False):
            return data

        # handle this here since form_part save causes problems with signals
        primary_category = data.get("primary_category")
        categories = data.get("categories", []) or []
        if categories:
            categories = list(categories)

        if not primary_category and categories:
            primary_category = categories[0]  # first is going to be primary

        if primary_category and primary_category not in categories:
            combined = [primary_category] + categories
            categories = combined

        data["primary_category"] = primary_category
        data["categories"] = categories

        form_post_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=data)
        return data
Пример #3
0
 def clean(self):
     form_pre_clean.send(Product,
                         instance=self.instance,
                         cleaned_data=self.cleaned_data)
     super(ProductBaseForm, self).clean()
     form_post_clean.send(Product,
                          instance=self.instance,
                          cleaned_data=self.cleaned_data)
Пример #4
0
    def clean(self):
        form_pre_clean.send(
            Product, instance=self.instance, cleaned_data=self.cleaned_data)
        super(ProductBaseForm, self).clean()

        if not settings.SHUUP_ADMIN_ALLOW_HTML_IN_PRODUCT_DESCRIPTION:
            for key, value in self.cleaned_data.items():
                if key.startswith("description__"):
                    self.cleaned_data[key] = bleach.clean(value, tags=[])

        form_post_clean.send(
            Product, instance=self.instance, cleaned_data=self.cleaned_data)
Пример #5
0
    def clean(self):
        form_pre_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=self.cleaned_data)
        data = super(ShopProductForm, self).clean()
        if not getattr(settings, "SHUUP_AUTO_SHOP_PRODUCT_CATEGORIES", False):
            return data

        # handle this here since form_part save causes problems with signals
        primary_category = data["primary_category"]
        categories = data["categories"]
        if not primary_category and categories:
            primary_category = categories[0]  # first is going to be primary
        if primary_category and primary_category not in categories:
            combined = [primary_category.pk] + list(categories.values_list("pk", flat=True))
            categories = Category.objects.filter(pk__in=combined)
        data["primary_category"] = primary_category
        data["categories"] = categories
        form_post_clean.send(
            ShopProduct, instance=self.instance, cleaned_data=data)
        return data
Пример #6
0
 def clean(self):
     form_pre_clean.send(
         Product, instance=self.instance, cleaned_data=self.cleaned_data)
     super(ProductBaseForm, self).clean()
     form_post_clean.send(
         Product, instance=self.instance, cleaned_data=self.cleaned_data)