#10895: Improvements in BRCPFField and BRCNPJField in localflavor.br.forms
------------------------------------------------------+---------------------
 Reporter:  luizvital                                 |       Owner:  nobody    
   Status:  new                                       |   Milestone:            
Component:  django.contrib.localflavor                |     Version:  SVN       
 Keywords:  brcpffield, brcpnjfield, br, localflavor  |       Stage:  Unreviewed
Has_patch:  1                                         |  
------------------------------------------------------+---------------------
 When using the fields `BRCPFField` and `BRCNPJField` in
 `django.contrib.localflavor.br.forms` I missed a uniform return format in
 the cleaned value of these fields, as they validate formatted and digits
 only inputs and the cleaned data preserves the same format as the entered
 value. If you're not enforcing a particular format with JavaScript, you
 may end up with a non standardized values on the database.

 Ex.: For `BRCPFField `the values cleaned can be '999.999.999-99',
 '99999999999', '999999999-99', etc...

 My suggestion is to keep the diversity of valid input formats, but provide
 a way to uniform the format of the cleaned value.

 The implementation consists of adding two optional keyword arguments:

  * `always_return_formatted`: a boolean which indicates if the cleaned
 value must always be in a particular format, the default is `False` to
 prevent unexpected behavior to the current users of this `FormField`
 class.
  * `return_format`: a string to format the output, defaults to
 '%s.%s.%s-%s' in `BRCPFField`

 In addition to these, I've changed the parent class of `BRCNPJField` from
 `Field` to `CharField` to take advantage of `max_length` and `min_length`
 validators.

 Tests for these features included and fixed some errors in previous
 doctest that were expecting a unicode string.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10895>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to