示例#1
0
 def clean(self, value):
     value = super(BrPlacaVeicularField, self).clean(value)
     if value in EMPTY_VALUES:
         return u''
     if len(value) == 7: # formato "AAA1111"
         value = mask_placa(value)
         pass
     if len(value) != 8: # formato "AAA-1111"
         raise forms.ValidationError(self.error_messages['invalid'])
     grupos = value.split('-')
     if not grupos[0].isalpha():
         raise forms.ValidationError(self.error_messages['invalid'])
     else:
         letras = grupos[0].upper()
     if not grupos[1].isdigit():  
         raise forms.ValidationError(self.error_messages['invalid'])
     return letras + '-' + grupos[1]
示例#2
0
 def clean(self, value):
     value = super(BrPlacaVeicularField, self).clean(value)
     if value in EMPTY_VALUES:
         return u''
     if len(value) == 7: # formato "AAA1111"
         value = mask_placa(value)
         pass
     if len(value) != 8: # formato "AAA-1111"
         raise forms.ValidationError(self.error_messages['invalid'])
     grupos = value.split('-')
     if not grupos[0].isalpha():
         raise forms.ValidationError(self.error_messages['invalid'])
     else:
         letras = grupos[0].upper()
     if not grupos[1].isdigit():  
         raise forms.ValidationError(self.error_messages['invalid'])
     return letras + '-' + grupos[1]
示例#3
0
 def render(self, name, value, attrs=None):
     if value and len(value) == 7:
         value = mask_placa(value)
     return super(self.__class__, self).render(name, value, attrs=attrs)
示例#4
0
 def render(self, name, value, attrs=None):
     if value and len(value) == 7:
         value = mask_placa(value)
     return super(self.__class__, self).render(name, value, attrs=attrs)