39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
from django import forms
|
|
from .models import CommentoSerieTV,SegnalazioneSerieTV
|
|
from utils.profanity_filter import profanity_words
|
|
from django.core.validators import ValidationError
|
|
|
|
class CommentiForms(forms.ModelForm):
|
|
class Meta:
|
|
model = CommentoSerieTV
|
|
fields = ['commento']
|
|
widgets = {
|
|
'commento' : forms.Textarea(attrs={'class': 'form__textarea','id':'text'})
|
|
}
|
|
|
|
def clean_commento(self):
|
|
super().clean()
|
|
dati = self.cleaned_data["commento"]
|
|
print(f" Hai scritto la parola : {dati}")
|
|
lista_parole_offensive = profanity_words()
|
|
for s in lista_parole_offensive:
|
|
if s in dati:
|
|
raise ValidationError("Il Contenuto Inserito viola le norme del sito! ")
|
|
return dati
|
|
|
|
class SearchTVShowAPI(forms.Form):
|
|
serie_tv = forms.CharField(label="",widget=forms.TextInput(attrs={'class': 'form__input','placeholder':'Titolo SerieTV...'}))
|
|
|
|
|
|
class SegnalazioneSerieTVForm(forms.ModelForm):
|
|
class Meta:
|
|
model = SegnalazioneSerieTV
|
|
exclude = ['serietv']
|
|
widgets = {
|
|
'descrizione_problema' : forms.Textarea(attrs={'class': 'form__textarea','id':'text'}),
|
|
'problema_video' : forms.Select(attrs={'class':' js-example-basic-single select2-hidden-accessible','id':'segnalaproblema'})
|
|
}
|
|
labels = {
|
|
'descrizione_problema': '',
|
|
'problema_video' : ''
|
|
} |