Source code for shuup.campaigns.admin_module.forms._basket_conditions
# This file is part of Shuup.
#
# Copyright (c) 2012-2021, Shuup Commerce Inc. All rights reserved.
#
# This source code is licensed under the OSL-3.0 license found in the
# LICENSE file in the root directory of this source tree.
from django import forms
from shuup.admin.forms.fields import WeekdayField
from shuup.admin.forms.widgets import TimeInput
from shuup.campaigns.models.basket_conditions import (
BasketMaxTotalAmountCondition,
BasketMaxTotalProductAmountCondition,
BasketTotalAmountCondition,
BasketTotalProductAmountCondition,
BasketTotalUndiscountedProductAmountCondition,
CategoryProductsBasketCondition,
ChildrenProductCondition,
ContactBasketCondition,
ContactGroupBasketCondition,
HourBasketCondition,
ProductsInBasketCondition,
)
from shuup.core.models import Category
from ._base import BaseRuleModelForm
[docs]class ProductsInBasketConditionForm(BaseRuleModelForm):
def __init__(self, *args, **kwargs):
super(ProductsInBasketConditionForm, self).__init__(*args, **kwargs)
self.fields["products"].widget = forms.SelectMultiple(attrs={"data-model": "shuup.product"})
[docs]class ChildrenProductConditionForm(BaseRuleModelForm):
def __init__(self, *args, **kwargs):
super(ChildrenProductConditionForm, self).__init__(*args, **kwargs)
self.fields["product"].widget = forms.Select(
attrs={"data-model": "shuup.product", "data-search-mode": "parent_product"}
)
[docs]class CategoryProductsBasketConditionForm(BaseRuleModelForm):
def __init__(self, **kwargs):
super(CategoryProductsBasketConditionForm, self).__init__(**kwargs)
self.fields["categories"].queryset = Category.objects.all_except_deleted()
self.fields["excluded_categories"].queryset = Category.objects.all_except_deleted()