3
3
from django .utils .translation import ugettext_lazy as _
4
4
5
5
6
- def foobar ():
7
- return 'foobar'
8
-
9
-
10
- class CustomField (models .CharField ):
11
-
12
- def __init__ (self , * args , ** kwargs ):
13
- kwargs ['max_length' ] = 12
14
- super (CustomField , self ).__init__ (* args , ** kwargs )
15
-
16
-
17
6
class RESTFrameworkModel (models .Model ):
18
7
"""
19
8
Base for test models that sets app_label, so they play nicely.
20
9
"""
10
+
21
11
class Meta :
22
12
app_label = 'tests'
23
13
abstract = True
24
14
25
15
26
- class HasPositiveIntegerAsChoice (RESTFrameworkModel ):
27
- some_choices = ((1 , 'A' ), (2 , 'B' ), (3 , 'C' ))
28
- some_integer = models .PositiveIntegerField (choices = some_choices )
29
-
30
-
31
- class Anchor (RESTFrameworkModel ):
32
- text = models .CharField (max_length = 100 , default = 'anchor' )
33
-
34
-
35
16
class BasicModel (RESTFrameworkModel ):
36
17
text = models .CharField (max_length = 100 , verbose_name = _ ("Text comes here" ), help_text = _ ("Text description." ))
37
18
@@ -41,24 +22,6 @@ class SlugBasedModel(RESTFrameworkModel):
41
22
slug = models .SlugField (max_length = 32 )
42
23
43
24
44
- class DefaultValueModel (RESTFrameworkModel ):
45
- text = models .CharField (default = 'foobar' , max_length = 100 )
46
- extra = models .CharField (blank = True , null = True , max_length = 100 )
47
-
48
-
49
- class CallableDefaultValueModel (RESTFrameworkModel ):
50
- text = models .CharField (default = foobar , max_length = 100 )
51
-
52
-
53
- class ManyToManyModel (RESTFrameworkModel ):
54
- rel = models .ManyToManyField (Anchor , help_text = 'Some help text.' )
55
-
56
-
57
- class ReadOnlyManyToManyModel (RESTFrameworkModel ):
58
- text = models .CharField (max_length = 100 , default = 'anchor' )
59
- rel = models .ManyToManyField (Anchor )
60
-
61
-
62
25
class BaseFilterableItem (RESTFrameworkModel ):
63
26
text = models .CharField (max_length = 100 )
64
27
@@ -72,72 +35,12 @@ class FilterableItem(BaseFilterableItem):
72
35
73
36
74
37
# Model for regression test for #285
75
-
76
38
class Comment (RESTFrameworkModel ):
77
39
email = models .EmailField ()
78
40
content = models .CharField (max_length = 200 )
79
41
created = models .DateTimeField (auto_now_add = True )
80
42
81
43
82
- class ActionItem (RESTFrameworkModel ):
83
- title = models .CharField (max_length = 200 )
84
- started = models .NullBooleanField (default = False )
85
- done = models .BooleanField (default = False )
86
- info = CustomField (default = '---' , max_length = 12 )
87
-
88
-
89
- # Models for reverse relations
90
- class Person (RESTFrameworkModel ):
91
- name = models .CharField (max_length = 10 )
92
- age = models .IntegerField (null = True , blank = True )
93
-
94
- @property
95
- def info (self ):
96
- return {
97
- 'name' : self .name ,
98
- 'age' : self .age ,
99
- }
100
-
101
-
102
- class BlogPost (RESTFrameworkModel ):
103
- title = models .CharField (max_length = 100 )
104
- writer = models .ForeignKey (Person , null = True , blank = True )
105
-
106
- def get_first_comment (self ):
107
- return self .blogpostcomment_set .all ()[0 ]
108
-
109
-
110
- class BlogPostComment (RESTFrameworkModel ):
111
- text = models .TextField ()
112
- blog_post = models .ForeignKey (BlogPost )
113
-
114
-
115
- class Album (RESTFrameworkModel ):
116
- title = models .CharField (max_length = 100 , unique = True )
117
- ref = models .CharField (max_length = 10 , unique = True , null = True , blank = True )
118
-
119
-
120
- class Photo (RESTFrameworkModel ):
121
- description = models .TextField ()
122
- album = models .ForeignKey (Album )
123
-
124
-
125
- # Model for issue #324
126
- class BlankFieldModel (RESTFrameworkModel ):
127
- title = models .CharField (max_length = 100 , blank = True , null = False ,
128
- default = "title" )
129
-
130
-
131
- # Model for issue #380
132
- class OptionalRelationModel (RESTFrameworkModel ):
133
- other = models .ForeignKey ('OptionalRelationModel' , blank = True , null = True )
134
-
135
-
136
- # Model for RegexField
137
- class Book (RESTFrameworkModel ):
138
- isbn = models .CharField (max_length = 13 )
139
-
140
-
141
44
# Models for relations tests
142
45
# ManyToMany
143
46
class ManyToManyTarget (RESTFrameworkModel ):
0 commit comments