Django

Code

Changeset 4955

Show
Ignore:
Timestamp:
04/08/07 08:22:48 (1 year ago)
Author:
russellm
Message:

Fixed #3876 -- Added Australian local flavour. Thanks, Matthew Flanagan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r4937 r4955  
    8989    Marc Fargas <telenieko@telenieko.com> 
    9090    favo@exoweb.net 
     91    Matthew Flanagan <http://wadofstuff.blogspot.com> 
    9192    Eric Floehr <eric@intellovations.com> 
    9293    Jorge Gajon <gajon@gajon.org> 
  • django/trunk/tests/regressiontests/forms/localflavor.py

    r4954 r4955  
    883883... 
    884884ValidationError: [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.'] 
     885 
     886## AUPostCodeField ########################################################## 
     887 
     888A field that accepts a four digit Australian post code. 
     889 
     890>>> from django.contrib.localflavor.au.forms import AUPostCodeField 
     891>>> f = AUPostCodeField() 
     892>>> f.clean('1234') 
     893u'1234' 
     894>>> f.clean('2000') 
     895u'2000' 
     896>>> f.clean('abcd') 
     897Traceback (most recent call last): 
     898... 
     899ValidationError: [u'Enter a 4 digit post code.'] 
     900>>> f.clean('20001') 
     901Traceback (most recent call last): 
     902... 
     903ValidationError: [u'Enter a 4 digit post code.'] 
     904>>> f.clean(None) 
     905Traceback (most recent call last): 
     906... 
     907ValidationError: [u'This field is required.'] 
     908>>> f.clean('') 
     909Traceback (most recent call last): 
     910... 
     911ValidationError: [u'This field is required.'] 
     912 
     913>>> f = AUPostCodeField(required=False) 
     914>>> f.clean('1234') 
     915u'1234' 
     916>>> f.clean('2000') 
     917u'2000' 
     918>>> f.clean('abcd') 
     919Traceback (most recent call last): 
     920... 
     921ValidationError: [u'Enter a 4 digit post code.'] 
     922>>> f.clean('20001') 
     923Traceback (most recent call last): 
     924... 
     925ValidationError: [u'Enter a 4 digit post code.'] 
     926>>> f.clean(None) 
     927u'' 
     928>>> f.clean('') 
     929u'' 
     930 
     931## AUPhoneNumberField ######################################################## 
     932 
     933A field that accepts a 10 digit Australian phone number. 
     934llows spaces and parentheses around area code. 
     935 
     936>>> from django.contrib.localflavor.au.forms import AUPhoneNumberField 
     937>>> f = AUPhoneNumberField() 
     938>>> f.clean('1234567890') 
     939u'1234567890' 
     940>>> f.clean('0213456789') 
     941u'0213456789' 
     942>>> f.clean('02 13 45 67 89') 
     943u'0213456789' 
     944>>> f.clean('(02) 1345 6789') 
     945u'0213456789' 
     946>>> f.clean('(02) 1345-6789') 
     947u'0213456789' 
     948>>> f.clean('(02)1345-6789') 
     949u'0213456789' 
     950>>> f.clean('0408 123 456') 
     951u'0408123456' 
     952>>> f.clean('123') 
     953Traceback (most recent call last): 
     954... 
     955ValidationError: [u'Phone numbers must contain 10 digits.'] 
     956>>> f.clean('1800DJANGO') 
     957Traceback (most recent call last): 
     958... 
     959ValidationError: [u'Phone numbers must contain 10 digits.'] 
     960>>> f.clean(None) 
     961Traceback (most recent call last): 
     962... 
     963ValidationError: [u'This field is required.'] 
     964>>> f.clean('') 
     965Traceback (most recent call last): 
     966... 
     967ValidationError: [u'This field is required.'] 
     968 
     969>>> f = AUPhoneNumberField(required=False) 
     970>>> f.clean('1234567890') 
     971u'1234567890' 
     972>>> f.clean('0213456789') 
     973u'0213456789' 
     974>>> f.clean('02 13 45 67 89') 
     975u'0213456789' 
     976>>> f.clean('(02) 1345 6789') 
     977u'0213456789' 
     978>>> f.clean('(02) 1345-6789') 
     979u'0213456789' 
     980>>> f.clean('(02)1345-6789') 
     981u'0213456789' 
     982>>> f.clean('0408 123 456') 
     983u'0408123456' 
     984>>> f.clean('123') 
     985Traceback (most recent call last): 
     986... 
     987ValidationError: [u'Phone numbers must contain 10 digits.'] 
     988>>> f.clean('1800DJANGO') 
     989Traceback (most recent call last): 
     990... 
     991ValidationError: [u'Phone numbers must contain 10 digits.'] 
     992>>> f.clean(None) 
     993u'' 
     994>>> f.clean('') 
     995u'' 
     996 
     997## AUStateSelect ############################################################# 
     998 
     999AUStateSelect is a Select widget that uses a list of Australian 
     1000states/territories as its choices. 
     1001 
     1002>>> from django.contrib.localflavor.au.forms import AUStateSelect 
     1003>>> f = AUStateSelect() 
     1004>>> print f.render('state', 'NSW') 
     1005<select name="state"> 
     1006<option value="ACT">Australian Capital Territory</option> 
     1007<option value="NSW" selected="selected">New South Wales</option> 
     1008<option value="NT">Northern Territory</option> 
     1009<option value="QLD">Queensland</option> 
     1010<option value="SA">South Australia</option> 
     1011<option value="TAS">Tasmania</option> 
     1012<option value="VIC">Victoria</option> 
     1013<option value="WA">Western Australia</option> 
     1014</select> 
    8851015"""