<commit_before>from django.conf import settings
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, ValidationError
from django.forms import fields, widgets, ModelChoiceField
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
from django.utils.html import format_html
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
from entangled.forms import EntangledModelFormMixin, get_related_object

if 'cmsplugin_cascade' not in settings.INSTALLED_APPS:
    raise ImproperlyConfigured("Please add 'cmsplugin_cascade' to your INSTALLED_APPS")

from cms.plugin_pool import plugin_pool
from cmsplugin_cascade.plugin_base import CascadePluginBase
from cmsplugin_cascade.link.forms import LinkForm, HeavySelectWidget
from cmsplugin_cascade.link.plugin_base import LinkPluginBase, LinkElementMixin
from shop.conf import app_settings
from shop.forms.base import DialogFormMixin
from shop.models.cart import CartModel
from shop.models.product import ProductModel


class ShopPluginBase(CascadePluginBase):
    module = "Shop"
    require_parent = False
    allow_children = False


class ProductSelectField(ModelChoiceField):
    widget = HeavySelectWidget(data_view='shop:select-product')

    def __init__(self, *args, **kwargs):
        kwargs.setdefault('queryset', ProductModel.objects.all())
        super().__init__(*args, **kwargs)


class CatalogLinkForm(LinkForm):
    """
    Alternative implementation of `cmsplugin_cascade.link.forms.LinkForm`, which allows to link onto
    the Product model, using its method ``get_absolute_url``.

    Note: In this form class the field ``product`` is missing. It is added later, when the shop's
    Product knows about its materialized model.<commit_msg>remove unused imports<commit_after>from django.conf import settings
from django.apps import apps
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, ValidationError
from django.forms import fields, widgets, ModelChoiceField
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
from django.utils.html import format_html
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
from entangled.forms import EntangledModelFormMixin, get_related_object

if 'cmsplugin_cascade' not in settings.INSTALLED_APPS:
    raise ImproperlyConfigured("Please add 'cmsplugin_cascade' to your INSTALLED_APPS")

from cms.plugin_pool import plugin_pool
from cmsplugin_cascade.plugin_base import CascadePluginBase
from cmsplugin_cascade.link.forms import LinkForm, HeavySelectWidget
from cmsplugin_cascade.link.plugin_base import LinkPluginBase
from shop.conf import app_settings
from shop.forms.base import DialogFormMixin
from shop.models.cart import CartModel
from shop.models.product import ProductModel


class ShopPluginBase(CascadePluginBase):
    module = "Shop"
    require_parent = False
    allow_children = False


class ProductSelectField(ModelChoiceField):
    widget = HeavySelectWidget(data_view='shop:select-product')

    def __init__(self, *args, **kwargs):
        kwargs.setdefault('queryset', ProductModel.objects.all())
        super().__init__(*args, **kwargs)


class CatalogLinkForm(LinkForm):
    """
    Alternative implementation of `cmsplugin_cascade.link.forms.LinkForm`, which allows to link onto
    the Product model, using its method ``get_absolute_url``.

    Note: In this form class the field ``product`` is missing. It is added later, when the shop's
    Product knows about its materialized model.
{'fraction_non_alphanumeric': 0.06528747984954325, 'fraction_numerical': 0.0, 'mean_word_length': 5.894444444444445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6172224', 'n_tokens_mistral': 1017, 'n_tokens_neox': 998, 'n_words': 308}