Code

Ticket #399: 399.diff

File 399.diff, 5.1 KB (added by Marc Fargas <telenieko@…>, 7 years ago)

Last patch with docs added.

Line 
1=== modified file 'django/contrib/admin/views/doc.py'
2--- django/contrib/admin/views/doc.py   2007-05-20 01:20:18 +0000
3+++ django/contrib/admin/views/doc.py   2007-05-20 21:06:31 +0000
4@@ -301,12 +301,14 @@
5     'ForeignKey'                : _('Integer'),
6     'ImageField'                : _('File path'),
7     'IntegerField'              : _('Integer'),
8+    'BigIntegerField'           : _('Integer'),
9     'IPAddressField'            : _('IP address'),
10     'ManyToManyField'           : '',
11     'NullBooleanField'          : _('Boolean (Either True, False or None)'),
12     'OneToOneField'             : _('Relation to parent model'),
13     'PhoneNumberField'          : _('Phone number'),
14     'PositiveIntegerField'      : _('Integer'),
15+    'PositiveBigIntegerField'   : _('Integer'),
16     'PositiveSmallIntegerField' : _('Integer'),
17     'SlugField'                 : _('String (up to %(maxlength)s)'),
18     'SmallIntegerField'         : _('Integer'),
19
20=== modified file 'django/db/backends/mysql/creation.py'
21--- django/db/backends/mysql/creation.py        2007-05-20 01:20:19 +0000
22+++ django/db/backends/mysql/creation.py        2007-05-20 21:06:31 +0000
23@@ -14,12 +14,14 @@
24     'FloatField':        'numeric(%(max_digits)s, %(decimal_places)s)',
25     'ImageField':        'varchar(100)',
26     'IntegerField':      'integer',
27+    'BigIntegerField':   'bigint',
28     'IPAddressField':    'char(15)',
29     'ManyToManyField':   None,
30     'NullBooleanField':  'bool',
31     'OneToOneField':     'integer',
32     'PhoneNumberField':  'varchar(20)',
33     'PositiveIntegerField': 'integer UNSIGNED',
34+    'PositiveBigIntegerField': 'bigint UNSIGNED',   
35     'PositiveSmallIntegerField': 'smallint UNSIGNED',
36     'SlugField':         'varchar(%(maxlength)s)',
37     'SmallIntegerField': 'smallint',
38
39=== modified file 'django/db/backends/mysql/introspection.py'
40--- django/db/backends/mysql/introspection.py   2007-05-20 01:20:19 +0000
41+++ django/db/backends/mysql/introspection.py   2007-05-20 21:06:31 +0000
42@@ -83,7 +83,7 @@
43     FIELD_TYPE.FLOAT: 'FloatField',
44     FIELD_TYPE.INT24: 'IntegerField',
45     FIELD_TYPE.LONG: 'IntegerField',
46-    FIELD_TYPE.LONGLONG: 'IntegerField',
47+    FIELD_TYPE.LONGLONG: 'BigIntegerField',
48     FIELD_TYPE.SHORT: 'IntegerField',
49     FIELD_TYPE.STRING: 'CharField',
50     FIELD_TYPE.TIMESTAMP: 'DateTimeField',
51
52=== modified file 'django/db/models/fields/__init__.py'
53--- django/db/models/fields/__init__.py 2007-05-20 01:20:19 +0000
54+++ django/db/models/fields/__init__.py 2007-05-20 21:06:31 +0000
55@@ -729,6 +729,14 @@
56         defaults.update(kwargs)
57         return super(IntegerField, self).formfield(**defaults)
58 
59+class BigIntegerField(IntegerField):
60+    def get_manipulator_field_objs(self):
61+        return [oldforms.BigIntegerField]
62+
63+class PositiveBigIntegerField(IntegerField):
64+    def get_manipulator_field_objs(self):
65+        return [oldforms.PositiveBigIntegerField]   
66+
67 class IPAddressField(Field):
68     def __init__(self, *args, **kwargs):
69         kwargs['maxlength'] = 15
70
71=== modified file 'django/oldforms/__init__.py'
72--- django/oldforms/__init__.py 2007-05-20 01:20:20 +0000
73+++ django/oldforms/__init__.py 2007-05-20 21:06:31 +0000
74@@ -749,6 +749,20 @@
75         if not 0 <= int(field_data) <= 32767:
76             raise validators.CriticalValidationError, gettext("Enter a whole number between 0 and 32,767.")
77 
78+class BigIntegerField(IntegerField):
79+    def __init__(self, field_name, length=20, maxlength=None, is_required=False, validator_list=None, member_name=None):
80+        if validator_list is None: validator_list = []
81+        validator_list = [self.isInteger] + validator_list
82+        if member_name is not None:
83+            self.member_name = member_name
84+        IntegerField.__init__(self, field_name, length, maxlength, is_required, validator_list)
85+
86+class PositiveBigIntegerField(PositiveIntegerField):
87+    def __init__(self, field_name, length=20, maxlength=None, is_required=False, validator_list=None):
88+        if validator_list is None: validator_list = []
89+        validator_list = [self.isPositive] + validator_list
90+        IntegerField.__init__(self, field_name, length, maxlength, is_required, validator_list)
91+
92 class FloatField(TextField):
93     def __init__(self, field_name, max_digits, decimal_places, is_required=False, validator_list=None):
94         if validator_list is None: validator_list = []
95
96=== modified file 'docs/model-api.txt'
97--- docs/model-api.txt  2007-05-20 01:20:21 +0000
98+++ docs/model-api.txt  2007-05-20 21:11:00 +0000
99@@ -126,6 +126,15 @@
100 automatically be added to your model if you don't specify otherwise. See
101 `Automatic primary key fields`_.
102 
103+``BigIntegerField``
104+~~~~~~~~~~~~~~~~
105+
106+A big integer.
107+
108+The admin represents this as an ``<input type="text">`` (a single-line input).
109+
110+It like an ``IntegerField``, except that it fits bigger numbers.
111+
112 ``BooleanField``
113 ~~~~~~~~~~~~~~~~
114 
115@@ -353,6 +362,11 @@
116 A ``CharField`` that checks that the value is a valid U.S.A.-style phone
117 number (in the format ``XXX-XXX-XXXX``).
118 
119+``PositiveBigIntegerField``
120+~~~~~~~~~~~~~~~~
121+
122+Just like a ``BigIntegerField``, but must be positive.
123+
124 ``PositiveIntegerField``
125 ~~~~~~~~~~~~~~~~~~~~~~~~
126 
127