from django import forms

from apps.core.forms import StyledFormMixin

from .models import Message


class ContactForm(StyledFormMixin, forms.ModelForm):
    website = forms.CharField(required=False, widget=forms.TextInput(attrs={"tabindex": "-1", "autocomplete": "off"}))

    class Meta:
        model = Message
        fields = ["nom", "email", "sujet", "message"]
        widgets = {"message": forms.Textarea(attrs={"rows": 6})}
        labels = {"nom": "Votre nom", "email": "Votre email"}

    def clean_website(self):
        if self.cleaned_data.get("website"):
            raise forms.ValidationError("Envoi refusé.")
        return ""


class SubscribeForm(forms.Form):
    email = forms.EmailField()
