|
|
@ -65,18 +65,14 @@ class PeriodoForm(forms.ModelForm): |
|
|
raise ValidationError('A Data Final não pode ser menor que ' |
|
|
raise ValidationError('A Data Final não pode ser menor que ' |
|
|
'a Data Inicial') |
|
|
'a Data Inicial') |
|
|
|
|
|
|
|
|
legislatura = Legislatura.objects.filter(data_inicio__gte=data_inicio, |
|
|
legislatura = Legislatura.objects.filter(data_inicio__lte=data_inicio, |
|
|
data_fim__lte=data_fim) |
|
|
data_fim__gte=data_fim) |
|
|
|
|
|
|
|
|
if not legislatura: |
|
|
if not legislatura: |
|
|
raise ValidationError('O período informado ' |
|
|
raise ValidationError('O período informado ' |
|
|
'deve estar contido em alguma ' |
|
|
'deve estar contido em uma única ' |
|
|
'legislatura existente') |
|
|
'legislatura existente') |
|
|
|
|
|
|
|
|
if len(legislatura) > 1: |
|
|
|
|
|
raise ValidationError('O período informado ' |
|
|
|
|
|
'deve estar contido apenas em uma única ' |
|
|
|
|
|
'legislatura existente') |
|
|
|
|
|
|
|
|
|
|
|
return cleaned_data |
|
|
return cleaned_data |
|
|
|
|
|
|
|
|
|