from django_recaptcha.fields import ReCaptchaField

from ocyan.main.loading import get_baseclass

from ocyan.plugin.google.constants import CAPTCHA_ENABLED
from ocyan.plugin.google.recaptcha import RECAPTCHA_WIDGET

BaseProductAlertForm = get_baseclass(
    "customer.forms",
    "ProductAlertForm",
    "ocyan.plugin.google.google_customer_extension",
)


class ProductAlertForm(BaseProductAlertForm):
    if CAPTCHA_ENABLED:
        captcha = ReCaptchaField(widget=RECAPTCHA_WIDGET, label="")

        class Meta(BaseProductAlertForm.Meta):
            fields = BaseProductAlertForm.Meta.fields + ["captcha"]
