| 1821 | |
| 1822 | # ESPostalCodeField ############################################################# |
| 1823 | |
| 1824 | ESPostalCodeField validates that the data is a valid ES postal code. |
| 1825 | >>> from django.contrib.localflavor.es.forms import * |
| 1826 | >>> f = ESPostalCodeField() |
| 1827 | >>> f.clean('01000') |
| 1828 | u'01000' |
| 1829 | >>> f.clean('52999') |
| 1830 | u'52999' |
| 1831 | >>> f.clean('00999') |
| 1832 | Traceback (most recent call last): |
| 1833 | ... |
| 1834 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1835 | >>> f.clean('53000') |
| 1836 | Traceback (most recent call last): |
| 1837 | ... |
| 1838 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1839 | >>> f.clean('0A200') |
| 1840 | Traceback (most recent call last): |
| 1841 | ... |
| 1842 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1843 | >>> f.clean('380001') |
| 1844 | Traceback (most recent call last): |
| 1845 | ... |
| 1846 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1847 | >>> f.clean(None) |
| 1848 | Traceback (most recent call last): |
| 1849 | ... |
| 1850 | ValidationError: [u'This field is required.'] |
| 1851 | >>> f.clean('') |
| 1852 | Traceback (most recent call last): |
| 1853 | ... |
| 1854 | ValidationError: [u'This field is required.'] |
| 1855 | |
| 1856 | >>> f = ESPostalCodeField(required=False) |
| 1857 | >>> f.clean('01000') |
| 1858 | u'01000' |
| 1859 | >>> f.clean('52999') |
| 1860 | u'52999' |
| 1861 | >>> f.clean('00999') |
| 1862 | Traceback (most recent call last): |
| 1863 | ... |
| 1864 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1865 | >>> f.clean('53000') |
| 1866 | Traceback (most recent call last): |
| 1867 | ... |
| 1868 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1869 | >>> f.clean('2A200') |
| 1870 | Traceback (most recent call last): |
| 1871 | ... |
| 1872 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1873 | >>> f.clean('380001') |
| 1874 | Traceback (most recent call last): |
| 1875 | ... |
| 1876 | ValidationError: [u'Enter a valid postal code in the range and format 01XXX - 52XXX.'] |
| 1877 | >>> f.clean(None) |
| 1878 | u'' |
| 1879 | >>> f.clean('') |
| 1880 | u'' |
| 1881 | |
| 1882 | # ESSubdivisionSelect ############################################################### |
| 1883 | |
| 1884 | ESSubdivisionSelect |
| 1885 | >>> w = ESSubdivisionSelect() |
| 1886 | >>> w.render('provinces', 'TF') |
| 1887 | u'<select name="provinces">\n<option value="VI">\xc1lava</option>\n<option value="AB">Albacete</option>\n<option value="A">Alicante</option>\n<option value="AL">Almer\xeda</option>\n<option value="O">Asturias</option>\n<option value="AV">\xc1vila</option>\n<option value="BA">Badajoz</option>\n<option value="PM">Islas Baleares</option>\n<option value="B">Barcelona</option>\n<option value="Bu">Burgos</option>\n<option value="CC">C\xe1ceres</option>\n<option value="CA">C\xe1diz</option>\n<option value="S">Cantabria</option>\n<option value="CS">Castell\xf3n</option>\n<option value="CE">Ceuta</option>\n<option value="CR">Ciudad Real</option>\n<option value="CO">C\xf3rdoba</option>\n<option value="Cu">Cuenca</option>\n<option value="GI">Gerona</option>\n<option value="GR">Granada</option>\n<option value="Gu">Guadalajara</option>\n<option value="SS">Guip\xfazcoa</option>\n<option value="H">Huelva</option>\n<option value="Hu">Huesca</option>\n<option value="J">Ja\xe9n</option>\n<option value="C">La Coru\xf1a</option>\n<option value="LO">La Rioja</option>\n<option value="GC">Las Palmas</option>\n<option value="LE">Le\xf3n</option>\n<option value="L">L\xe9rida</option>\n<option value="Lu">Lugo</option>\n<option value="M">Madrid</option>\n<option value="MA">M\xe1laga</option>\n<option value="ML">Melilla</option>\n<option value="Mu">Murcia</option>\n<option value="NA">Navarra</option>\n<option value="OR">Orense</option>\n<option value="P">Palencia</option>\n<option value="PO">Pontevedra</option>\n<option value="SA">Salamanca</option>\n<option value="TF" selected="selected">Santa Cruz de Tenerife</option>\n<option value="SG">Segovia</option>\n<option value="SE">Sevilla</option>\n<option value="SO">Soria</option>\n<option value="T">Tarragona</option>\n<option value="TE">Teruel</option>\n<option value="TO">Toledo</option>\n<option value="V">Valencia</option>\n<option value="VA">Valladolid</option>\n<option value="BI">Vizcaya</option>\n<option value="ZA">Zamora</option>\n<option value="Z">Zaragoza</option>\n</select>' |
| 1888 | |
| 1889 | # ESIdentityCardNumberField ############################################################# |
| 1890 | |
| 1891 | ESIdentityCardNumberField |
| 1892 | >>> f = ESIdentityCardNumberField() |
| 1893 | >>> f.clean('78699688J') |
| 1894 | u'78699688J' |
| 1895 | >>> f.clean('78699688-J') |
| 1896 | u'78699688J' |
| 1897 | >>> f.clean('78699688 J') |
| 1898 | u'78699688J' |
| 1899 | >>> f.clean('78699688 j') |
| 1900 | u'78699688J' |
| 1901 | >>> f.clean('78699688T') |
| 1902 | Traceback (most recent call last): |
| 1903 | ... |
| 1904 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1905 | >>> f.clean('X0901797J') |
| 1906 | u'X0901797J' |
| 1907 | >>> f.clean('X-6124387-Q') |
| 1908 | u'X6124387Q' |
| 1909 | >>> f.clean('X 0012953 G') |
| 1910 | u'X0012953G' |
| 1911 | >>> f.clean('x-3287690-r') |
| 1912 | u'X3287690R' |
| 1913 | >>> f.clean('X-03287690r') |
| 1914 | u'X03287690R' |
| 1915 | >>> f.clean('X-03287690') |
| 1916 | Traceback (most recent call last): |
| 1917 | ... |
| 1918 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1919 | >>> f.clean('X-03287690-T') |
| 1920 | Traceback (most recent call last): |
| 1921 | ... |
| 1922 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1923 | >>> f.clean('B38790911') |
| 1924 | u'B38790911' |
| 1925 | >>> f.clean('B-3879091A') |
| 1926 | Traceback (most recent call last): |
| 1927 | ... |
| 1928 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1929 | >>> f.clean('B 38790917') |
| 1930 | Traceback (most recent call last): |
| 1931 | ... |
| 1932 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1933 | >>> f.clean('P-3900800-H') |
| 1934 | u'P3900800H' |
| 1935 | >>> f.clean('P 39008008') |
| 1936 | Traceback (most recent call last): |
| 1937 | ... |
| 1938 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1939 | >>> f.clean('C-28795565') |
| 1940 | u'C28795565' |
| 1941 | >>> f.clean('C 2879556E') |
| 1942 | u'C2879556E' |
| 1943 | >>> f.clean('C28795567') |
| 1944 | Traceback (most recent call last): |
| 1945 | ... |
| 1946 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1947 | >>> f.clean('I38790911') |
| 1948 | Traceback (most recent call last): |
| 1949 | ... |
| 1950 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1951 | >>> f.clean('78699688-2') |
| 1952 | Traceback (most recent call last): |
| 1953 | ... |
| 1954 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1955 | >>> f.clean('999999999') |
| 1956 | Traceback (most recent call last): |
| 1957 | ... |
| 1958 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1959 | >>> f.clean(None) |
| 1960 | Traceback (most recent call last): |
| 1961 | ... |
| 1962 | ValidationError: [u'This field is required.'] |
| 1963 | >>> f.clean('') |
| 1964 | Traceback (most recent call last): |
| 1965 | ... |
| 1966 | ValidationError: [u'This field is required.'] |
| 1967 | >>> f = ESIdentityCardNumberField(required=False) |
| 1968 | >>> f.clean(None) |
| 1969 | u'' |
| 1970 | >>> f.clean('') |
| 1971 | u'' |
| 1972 | >>> f = ESIdentityCardNumberField() |
| 1973 | >>> f.clean('78699688J') |
| 1974 | u'78699688J' |
| 1975 | >>> f.clean('78699688T') |
| 1976 | Traceback (most recent call last): |
| 1977 | ... |
| 1978 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1979 | >>> f.clean('X-03287690-T') |
| 1980 | Traceback (most recent call last): |
| 1981 | ... |
| 1982 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1983 | >>> f.clean('B-3879091A') |
| 1984 | Traceback (most recent call last): |
| 1985 | ... |
| 1986 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1987 | >>> f.clean('P 39008008') |
| 1988 | Traceback (most recent call last): |
| 1989 | ... |
| 1990 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1991 | >>> f.clean('C28795567') |
| 1992 | Traceback (most recent call last): |
| 1993 | ... |
| 1994 | ValidationError: [u'Please enter a valid NIF, NIE or CIF.'] |
| 1995 | >>> f = ESIdentityCardNumberField(cif=False) |
| 1996 | >>> f.clean('78699688J') |
| 1997 | u'78699688J' |
| 1998 | >>> f.clean('X-6124387-Q') |
| 1999 | u'X6124387Q' |
| 2000 | >>> f.clean('B38790911') |
| 2001 | Traceback (most recent call last): |
| 2002 | ... |
| 2003 | ValidationError: [u'Please enter a valid NIF or NIE.'] |
| 2004 | >>> f = ESIdentityCardNumberField(nif=False) |
| 2005 | >>> f.clean('78699688J') |
| 2006 | Traceback (most recent call last): |
| 2007 | ... |
| 2008 | ValidationError: [u'Please enter a valid CIF.'] |
| 2009 | >>> f.clean('X-6124387-Q') |
| 2010 | Traceback (most recent call last): |
| 2011 | ... |
| 2012 | ValidationError: [u'Please enter a valid CIF.'] |
| 2013 | >>> f.clean('B38790911') |
| 2014 | u'B38790911' |