6
6
7
7
from django .core .exceptions import ValidationError
8
8
from django .core .urlresolvers import reverse
9
- from django .db import models
10
9
from django .conf import settings
10
+ from django .db import models
11
+ from django .utils .encoding import python_2_unicode_compatible
11
12
12
13
from .commits .github import GITHUB_URL_RE
13
14
14
15
16
+ @python_2_unicode_compatible
15
17
class Project (models .Model ):
16
18
NO_LOGS = 'N'
17
19
GIT = 'G'
@@ -38,7 +40,7 @@ class Project(models.Model):
38
40
blank = True , max_length = 200 )
39
41
track = models .BooleanField ("Track changes" , default = True )
40
42
41
- def __unicode__ (self ):
43
+ def __str__ (self ):
42
44
return self .name
43
45
44
46
@property
@@ -71,18 +73,20 @@ def save(self, *args, **kwargs):
71
73
super (Project , self ).save (* args , ** kwargs )
72
74
73
75
76
+ @python_2_unicode_compatible
74
77
class Branch (models .Model ):
75
78
name = models .CharField (max_length = 20 )
76
79
project = models .ForeignKey (Project , related_name = "branches" )
77
80
78
- def __unicode__ (self ):
81
+ def __str__ (self ):
79
82
return self .project .name + ":" + self .name
80
83
81
84
class Meta :
82
85
unique_together = ("name" , "project" )
83
86
verbose_name_plural = "branches"
84
87
85
88
89
+ @python_2_unicode_compatible
86
90
class Revision (models .Model ):
87
91
# git and mercurial's SHA-1 length is 40
88
92
commitid = models .CharField (max_length = 42 )
@@ -100,7 +104,7 @@ def get_short_commitid(self):
100
104
def get_browsing_url (self ):
101
105
return self .branch .project .commit_browsing_url .format (** self .__dict__ )
102
106
103
- def __unicode__ (self ):
107
+ def __str__ (self ):
104
108
if self .date is None :
105
109
date = None
106
110
else :
@@ -123,6 +127,7 @@ def clean(self):
123
127
raise ValidationError ("Invalid SVN commit id %s" % self .commitid )
124
128
125
129
130
+ @python_2_unicode_compatible
126
131
class Executable (models .Model ):
127
132
name = models .CharField (max_length = 30 )
128
133
description = models .CharField (max_length = 200 , blank = True )
@@ -131,10 +136,11 @@ class Executable(models.Model):
131
136
class Meta :
132
137
unique_together = ('name' , 'project' )
133
138
134
- def __unicode__ (self ):
139
+ def __str__ (self ):
135
140
return self .name
136
141
137
142
143
+ @python_2_unicode_compatible
138
144
class Benchmark (models .Model ):
139
145
B_TYPES = (
140
146
('C' , 'Cross-project' ),
@@ -154,7 +160,7 @@ class Benchmark(models.Model):
154
160
default_on_comparison = models .BooleanField (
155
161
"Default on comparison page" , default = True )
156
162
157
- def __unicode__ (self ):
163
+ def __str__ (self ):
158
164
return self .name
159
165
160
166
def clean (self ):
@@ -164,17 +170,19 @@ def clean(self):
164
170
"'default_on_comparison' first." )
165
171
166
172
173
+ @python_2_unicode_compatible
167
174
class Environment (models .Model ):
168
175
name = models .CharField (unique = True , max_length = 100 )
169
176
cpu = models .CharField (max_length = 100 , blank = True )
170
177
memory = models .CharField (max_length = 100 , blank = True )
171
178
os = models .CharField (max_length = 100 , blank = True )
172
179
kernel = models .CharField (max_length = 100 , blank = True )
173
180
174
- def __unicode__ (self ):
181
+ def __str__ (self ):
175
182
return self .name
176
183
177
184
185
+ @python_2_unicode_compatible
178
186
class Result (models .Model ):
179
187
value = models .FloatField ()
180
188
std_dev = models .FloatField (blank = True , null = True )
@@ -186,13 +194,14 @@ class Result(models.Model):
186
194
benchmark = models .ForeignKey (Benchmark , related_name = "results" )
187
195
environment = models .ForeignKey (Environment , related_name = "results" )
188
196
189
- def __unicode__ (self ):
197
+ def __str__ (self ):
190
198
return u"%s: %s" % (self .benchmark .name , self .value )
191
199
192
200
class Meta :
193
201
unique_together = ("revision" , "executable" , "benchmark" , "environment" )
194
202
195
203
204
+ @python_2_unicode_compatible
196
205
class Report (models .Model ):
197
206
revision = models .ForeignKey (Revision , related_name = "reports" )
198
207
environment = models .ForeignKey (Environment , related_name = "reports" )
@@ -201,7 +210,7 @@ class Report(models.Model):
201
210
colorcode = models .CharField (max_length = 10 , default = "none" )
202
211
_tablecache = models .TextField (blank = True )
203
212
204
- def __unicode__ (self ):
213
+ def __str__ (self ):
205
214
return u"Report for %s" % self .revision
206
215
207
216
class Meta :
@@ -534,3 +543,4 @@ def _get_tablecache(self):
534
543
if self ._tablecache == '' :
535
544
return {}
536
545
return json .loads (self ._tablecache )
546
+
0 commit comments