Code

Ticket #8664: 8664-1.diff

File 8664-1.diff, 3.3 KB (added by gkelly, 6 years ago)

Moves to django.contrib.localflavor.us.models. No additional changes.

Line 
1Index: django/db/models/fields/__init__.py
2===================================================================
3--- django/db/models/fields/__init__.py (revision 8731)
4+++ django/db/models/fields/__init__.py (working copy)
5@@ -725,16 +725,6 @@
6         defaults.update(kwargs)
7         return super(NullBooleanField, self).formfield(**defaults)
8 
9-class PhoneNumberField(Field):
10-    def get_internal_type(self):
11-        return "PhoneNumberField"
12-
13-    def formfield(self, **kwargs):
14-        from django.contrib.localflavor.us.forms import USPhoneNumberField
15-        defaults = {'form_class': USPhoneNumberField}
16-        defaults.update(kwargs)
17-        return super(PhoneNumberField, self).formfield(**defaults)
18-
19 class PositiveIntegerField(IntegerField):
20     def get_internal_type(self):
21         return "PositiveIntegerField"
22Index: django/contrib/localflavor/us/models.py
23===================================================================
24--- django/contrib/localflavor/us/models.py     (revision 0)
25+++ django/contrib/localflavor/us/models.py     (revision 0)
26@@ -0,0 +1,11 @@
27+from django.db.models.fields import Field
28+
29+class PhoneNumberField(Field):
30+    def get_internal_type(self):
31+        return "PhoneNumberField"
32+
33+    def formfield(self, **kwargs):
34+        from django.contrib.localflavor.us.forms import USPhoneNumberField
35+        defaults = {'form_class': USPhoneNumberField}
36+        defaults.update(kwargs)
37+        return super(PhoneNumberField, self).formfield(**defaults)
38Index: tests/modeltests/model_forms/models.py
39===================================================================
40--- tests/modeltests/model_forms/models.py      (revision 8731)
41+++ tests/modeltests/model_forms/models.py      (working copy)
42@@ -70,7 +70,8 @@
43     pass
44 
45 class PhoneNumber(models.Model):
46-    phone = models.PhoneNumberField()
47+    from django.contrib.localflavor.us.models import PhoneNumberField
48+    phone = PhoneNumberField()
49     description = models.CharField(max_length=20)
50 
51     def __unicode__(self):
52Index: tests/regressiontests/serializers_regress/models.py
53===================================================================
54--- tests/regressiontests/serializers_regress/models.py (revision 8731)
55+++ tests/regressiontests/serializers_regress/models.py (working copy)
56@@ -8,6 +8,7 @@
57 from django.db import models
58 from django.contrib.contenttypes import generic
59 from django.contrib.contenttypes.models import ContentType
60+from django.contrib.localflavor.us.models import PhoneNumberField
61 
62 # The following classes are for testing basic data
63 # marshalling, including NULL values.
64@@ -52,7 +53,7 @@
65     data = models.NullBooleanField(null=True)
66 
67 class PhoneData(models.Model):
68-    data = models.PhoneNumberField(null=True)
69+    data = PhoneNumberField(null=True)
70 
71 class PositiveIntegerData(models.Model):
72     data = models.PositiveIntegerField(null=True)
73@@ -188,7 +189,7 @@
74 #     data = models.NullBooleanField(primary_key=True)
75 
76 class PhonePKData(models.Model):
77-    data = models.PhoneNumberField(primary_key=True)
78+    data = PhoneNumberField(primary_key=True)
79 
80 class PositiveIntegerPKData(models.Model):
81     data = models.PositiveIntegerField(primary_key=True)
82@@ -251,4 +252,4 @@
83 class ExplicitInheritBaseModel(BaseModel):
84     parent = models.OneToOneField(BaseModel)
85     child_data = models.IntegerField()
86-   
87\ No newline at end of file
88+