class SimpleVariationChildForm(forms.Form):
    # TODO: Add a mode for ProductChoiceWidget to only allow eligible variation children to be selected
    child = forms.ModelChoiceField(
        queryset=Product.objects.all(),
        widget=ProductChoiceWidget(),
        label=_('child')
    )
 def _build_fields(self):
     for combo in self.parent_product.get_all_available_combinations():
         field = forms.ModelChoiceField(
             queryset=Product.objects.all(),
             # TODO: Add a mode for ProductChoiceWidget to only allow eligible variation children to be selected
             widget=ProductChoiceWidget(clearable=True),
             required=False,
             initial=combo["result_product_pk"],
             label=_("variable combination"))
         field.combo = combo
         self.fields["r_%s" % combo["hash"]] = field
Beispiel #3
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request")
        self.shop = get_shop(self.request)
        super(DiscountForm, self).__init__(*args, **kwargs)

        self.fields["availability_exceptions"].queryset = AvailabilityException.objects.filter(shops=self.shop)
        self.fields["category"].queryset = Category.objects.filter(shops=self.shop)
        self.fields["contact"].widget = ContactChoiceWidget(clearable=True)
        self.fields["contact_group"].queryset = ContactGroup.objects.filter(shop=self.shop)
        self.fields["coupon_code"].queryset = CouponCode.objects.filter(shops=self.shop)
        self.fields["happy_hours"].queryset = HappyHour.objects.filter(shops=self.shop)
        self.fields["product"].widget = ProductChoiceWidget(clearable=True)
        self.fields["supplier"].queryset = Supplier.objects.enabled(shop=self.shop)
Beispiel #4
0
    def __init__(self, **kwargs):
        self.carousel = kwargs.pop("carousel")
        super(SlideForm, self).__init__(**kwargs)

        self.empty_permitted = False
        self.fields["product_link"].widget = ProductChoiceWidget(
            clearable=True)
        for lang in self.languages:
            image_field = "image__%s" % lang
            self.fields[image_field].widget = ImageChoiceWidget(clearable=True)
            if lang == self.default_language:
                self.fields[image_field].widget = ImageChoiceWidget(
                    clearable=False)
                self.fields[image_field].required = True
                self.fields[image_field].widget.is_required = True
Beispiel #5
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request")
        self.shop = get_shop(self.request)
        super(DiscountForm, self).__init__(*args, **kwargs)

        self.fields["category"].queryset = Category.objects.filter(
            shops=self.shop)
        self.fields["contact"].widget = ContactChoiceWidget(clearable=True)
        self.fields["contact_group"].queryset = ContactGroup.objects.filter(
            Q(shop=self.shop) | Q(shop__isnull=True))
        self.fields["happy_hours"].queryset = HappyHour.objects.filter(
            shop=self.shop)
        self.fields["product"].widget = ProductChoiceWidget(clearable=True)
        self.fields["supplier"].queryset = Supplier.objects.enabled(
            shop=self.shop)
Beispiel #6
0
    def __init__(self, **kwargs):
        self.carousel = kwargs.pop("carousel")
        super(SlideForm, self).__init__(**kwargs)

        self.empty_permitted = False
        self.fields["product_link"].widget = ProductChoiceWidget(clearable=True)
        for lang in self.languages:
            image_field = "image__%s" % lang
            self.fields[image_field].widget = FileDnDUploaderWidget(
                kind="images", upload_path="/carousel", clearable=True)
            if lang == self.default_language:
                self.fields[image_field].widget = FileDnDUploaderWidget(
                    kind="images", upload_path="/carousel", clearable=False)
                self.fields[image_field].required = True
                self.fields[image_field].widget.is_required = True

        if not self.fields["available_from"].initial:
            self.fields["available_from"].initial = now()
Beispiel #7
0
    def __init__(self, **kwargs):
        self.carousel = kwargs.pop("carousel")
        self.request = kwargs.pop("request")
        super(SlideForm, self).__init__(**kwargs)
        self.empty_permitted = False
        shop = get_shop(self.request)
        self.fields["category_link"].queryset = Category.objects.all_except_deleted(
            shop=self.request.shop).prefetch_related('translations')
        self.fields["cms_page_link"].queryset = Page.objects.filter(shop=shop)
        self.fields["product_link"].widget = ProductChoiceWidget(clearable=True)
        for lang in self.languages:
            image_field = "image__%s" % lang
            self.fields[image_field].widget = FileDnDUploaderWidget(
                kind="images", upload_path="/carousel", clearable=True)
            if lang == self.default_language:
                self.fields[image_field].widget = FileDnDUploaderWidget(
                    kind="images", upload_path="/carousel", clearable=False)
                self.fields[image_field].required = True
                self.fields[image_field].widget.is_required = True

        if not self.fields["available_from"].initial:
            self.fields["available_from"].initial = now()
Beispiel #8
0
 def __init__(self, **kwargs):
     self.product = kwargs.pop("product")
     super(ProductCrossSellForm, self).__init__(**kwargs)
     self.fields["product2"].widget = ProductChoiceWidget()
     self.fields["product2"].label = _("Product")