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

BaseProductReviewForm = get_baseclass(
    "catalogue.reviews.forms",
    "ProductReviewForm",
    "ocyan.plugin.google.google_catalogue_review_extension.reviews",
)


class ProductReviewForm(BaseProductReviewForm):
    if CAPTCHA_ENABLED:
        captcha = ReCaptchaField(widget=RECAPTCHA_WIDGET, label="")

        class Meta(BaseProductReviewForm.Meta):
            fields = BaseProductReviewForm.Meta.fields
