Skip to content

Commit be193d9

Browse files
committed
updates for django>2
1 parent 782d959 commit be193d9

11 files changed

Lines changed: 51 additions & 61 deletions

File tree

codespeed/models.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@
99
from django.urls import reverse
1010
from django.conf import settings
1111
from django.db import models
12-
try:
13-
from django.utils.encoding import python_2_unicode_compatible
14-
except ImportError:
15-
def python_2_unicode_compatible(arg):
16-
return arg
1712

1813
from .commits.github import GITHUB_URL_RE
1914

2015
logger = logging.getLogger(__name__)
2116

2217

23-
@python_2_unicode_compatible
2418
class Project(models.Model):
2519
NO_LOGS = 'N'
2620
GIT = 'G'
@@ -106,7 +100,6 @@ def is_less_important_than(self, val, color):
106100
return False
107101

108102

109-
@python_2_unicode_compatible
110103
class Branch(models.Model):
111104
name = models.CharField(max_length=32)
112105
project = models.ForeignKey(
@@ -123,7 +116,6 @@ class Meta:
123116
verbose_name_plural = "branches"
124117

125118

126-
@python_2_unicode_compatible
127119
class Revision(models.Model):
128120
# git and mercurial's SHA-1 length is 40
129121
commitid = models.CharField(max_length=42)
@@ -166,7 +158,6 @@ def clean(self):
166158
raise ValidationError("Invalid SVN commit id %s" % self.commitid)
167159

168160

169-
@python_2_unicode_compatible
170161
class Executable(models.Model):
171162
name = models.CharField(max_length=30)
172163
description = models.CharField(max_length=200, blank=True)
@@ -180,7 +171,6 @@ def __str__(self):
180171
return self.name
181172

182173

183-
@python_2_unicode_compatible
184174
class Benchmark(models.Model):
185175
B_TYPES = (
186176
('C', 'Cross-project'),
@@ -215,7 +205,6 @@ def clean(self):
215205
"'default_on_comparison' first.")
216206

217207

218-
@python_2_unicode_compatible
219208
class Environment(models.Model):
220209
name = models.CharField(unique=True, max_length=100)
221210
cpu = models.CharField(max_length=100, blank=True)
@@ -227,7 +216,6 @@ def __str__(self):
227216
return self.name
228217

229218

230-
@python_2_unicode_compatible
231219
class Result(models.Model):
232220
value = models.FloatField()
233221
std_dev = models.FloatField(blank=True, null=True)
@@ -252,7 +240,6 @@ class Meta:
252240
unique_together = ("revision", "executable", "benchmark", "environment")
253241

254242

255-
@python_2_unicode_compatible
256243
class Report(models.Model):
257244
revision = models.ForeignKey(
258245
Revision, on_delete=models.CASCADE, related_name="reports")

codespeed/templates/codespeed/changes_data.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<td>{% if rev.get_browsing_url %}<a href="{{ rev.get_browsing_url }}">{{ rev.commitid }}</a>{% else %}{{ rev.commitid }}{% endif %}</td>
1818
</tr>
1919
<tr class="date"><th class="infofirst">Date</td><td>{{ rev.date }}</td></tr>
20-
{% ifnotequal rev.branch.project.repo_type "N" %}
20+
{% if rev.branch.project.repo_type != "N" %}
2121
<tr class="repo-path"><th class="infofirst">Repo</th><td>{{ rev.branch.project.repo_path }}</td></tr>
22-
{% endifnotequal %}
22+
{% endif %}
2323
</tbody>
2424
</table>
2525

26-
{% ifnotequal exe.project.repo_type 'N' %}
26+
{% if exe.project.repo_type != 'N' %}
2727
<table class="revision">
2828
<col/>
2929
<col/>
@@ -40,5 +40,5 @@
4040
el.load("logs/", "revisionid=" + el.data("commitid"));
4141
</script>
4242
</table>
43-
{% endifnotequal %}
43+
{% endif %}
4444
</div>

codespeed/templates/codespeed/changes_table.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{% endif%}{% if units.has_stddev %}<td>{{ units.totals.min }}</td>
2727
{% endif%}{% if units.hasmax %}<td>{{ units.totals.max }}</td>
2828
{% endif%}<td>{{ units.totals.change|percentage }}</td>
29-
<td>{% ifnotequal units.totals.trend "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endifnotequal %}</td>
29+
<td>{% if units.totals.trend != "-" %}{{ units.totals.trend|floatformat:2 }}%{% else %}{{ units.totals.trend }}{% endif %}</td>
3030
</tr>
3131
</tfoot>
3232
<tbody>
@@ -38,7 +38,7 @@
3838
{% endif%}{% if units.hasmin %}<td>{{ row.val_min|floatformat:units.precission }}</td>
3939
{% endif%}{% if units.hasmax %}<td>{{ row.val_max|floatformat:units.precission }}</td>
4040
{% endif%}<td>{{ row.change|percentage }}</td>
41-
<td>{% ifequal row.trend "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endifequal %}</td>
41+
<td>{% if row.trend == "-" %}-{% else %}{{ row.trend|floatformat:2 }}%{% endif %}</td>
4242
</tr>{% endfor %}
4343
</tbody>
4444
</table>{% endfor %}

codespeed/templates/codespeed/timeline.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</div>
5555
<div id="benchmark" class="sidebox">
5656
<div class="boxhead"><h2>Benchmark</h2></div>
57-
<div class="boxbody">{% ifnotequal benchmarks|length 1 %}
57+
<div class="boxbody">{% if benchmarks|length != 1 %}
5858
<ul>
5959
<li>
6060
<input id="benchmarkgrid" type="radio" name="benchmark" value="grid" />
@@ -64,7 +64,7 @@
6464
<input id="b_show_none" type="radio" name="benchmark" value="show_none" />
6565
<label for="b_show_none">Display none</label>
6666
</li>
67-
</ul>{% endifnotequal %}
67+
</ul>{% endif %}
6868
<ul>{% for bench in benchmarks|dictsort:"name" %}
6969
<li title="{{ bench.description }}">
7070
<input id="benchmark_{{ bench.id }}" type="radio" name="benchmark" value="{{ bench.name }}" />

codespeed/urls.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
# -*- coding: utf-8 -*-
2-
from django.conf.urls import url
2+
from django.urls import re_path
33
from django.views.generic import TemplateView
44

55
from codespeed import views
66
from codespeed.feeds import LatestEntries, LatestSignificantEntries
77

88
urlpatterns = [
9-
url(r'^$', views.HomeView.as_view(), name='home'),
10-
url(r'^about/$',
9+
re_path(r'^$', views.HomeView.as_view(), name='home'),
10+
re_path(r'^about/$',
1111
TemplateView.as_view(template_name='about.html'), name='about'),
1212
# RSS for reports
13-
url(r'^feeds/latest/$', LatestEntries(), name='latest-results'),
14-
url(r'^feeds/latest_significant/$', LatestSignificantEntries(),
13+
re_path(r'^feeds/latest/$', LatestEntries(), name='latest-results'),
14+
re_path(r'^feeds/latest_significant/$', LatestSignificantEntries(),
1515
name='latest-significant-results'),
1616
]
1717

1818
urlpatterns += [
19-
url(r'^historical/json/$', views.gethistoricaldata, name='gethistoricaldata'),
20-
url(r'^reports/$', views.reports, name='reports'),
21-
url(r'^changes/$', views.changes, name='changes'),
22-
url(r'^changes/table/$', views.getchangestable, name='getchangestable'),
23-
url(r'^changes/logs/$', views.displaylogs, name='displaylogs'),
24-
url(r'^timeline/$', views.timeline, name='timeline'),
25-
url(r'^timeline/json/$', views.gettimelinedata, name='gettimelinedata'),
26-
url(r'^comparison/$', views.comparison, name='comparison'),
27-
url(r'^comparison/json/$', views.getcomparisondata, name='getcomparisondata'),
28-
url(r'^makeimage/$', views.makeimage, name='makeimage'),
19+
re_path(r'^historical/json/$', views.gethistoricaldata, name='gethistoricaldata'),
20+
re_path(r'^reports/$', views.reports, name='reports'),
21+
re_path(r'^changes/$', views.changes, name='changes'),
22+
re_path(r'^changes/table/$', views.getchangestable, name='getchangestable'),
23+
re_path(r'^changes/logs/$', views.displaylogs, name='displaylogs'),
24+
re_path(r'^timeline/$', views.timeline, name='timeline'),
25+
re_path(r'^timeline/json/$', views.gettimelinedata, name='gettimelinedata'),
26+
re_path(r'^comparison/$', views.comparison, name='comparison'),
27+
re_path(r'^comparison/json/$', views.getcomparisondata, name='getcomparisondata'),
28+
re_path(r'^makeimage/$', views.makeimage, name='makeimage'),
2929
]
3030

3131
urlpatterns += [
3232
# URLs for adding results
33-
url(r'^result/add/json/$', views.add_json_results, name='add-json-results'),
34-
url(r'^result/add/$', views.add_result, name='add-result'),
33+
re_path(r'^result/add/json/$', views.add_json_results, name='add-json-results'),
34+
re_path(r'^result/add/$', views.add_result, name='add-result'),
3535
]

codespeed/views.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.http import HttpResponse, Http404, HttpResponseBadRequest, \
1212
HttpResponseNotFound, StreamingHttpResponse
1313
from django.db.models import F
14-
from django.shortcuts import get_object_or_404, render_to_response
14+
from django.shortcuts import get_object_or_404, render
1515
from django.views.decorators.http import require_GET, require_POST
1616
from django.views.decorators.csrf import csrf_exempt
1717
from django.views.generic.base import TemplateView
@@ -33,7 +33,7 @@
3333

3434
def no_environment_error(request):
3535
admin_url = reverse('admin:codespeed_environment_changelist')
36-
return render_to_response('codespeed/nodata.html', {
36+
return render(request, 'codespeed/nodata.html', {
3737
'message': ('You need to configure at least one Environment. '
3838
'Please go to the '
3939
'<a href="%s">admin interface</a>' % admin_url)
@@ -42,7 +42,7 @@ def no_environment_error(request):
4242

4343
def no_default_project_error(request):
4444
admin_url = reverse('admin:codespeed_project_changelist')
45-
return render_to_response('codespeed/nodata.html', {
45+
return render(request, 'codespeed/nodata.html', {
4646
'message': ('You need to configure at least one one Project as '
4747
'default (checked "Track changes" field).<br />'
4848
'Please go to the '
@@ -51,13 +51,13 @@ def no_default_project_error(request):
5151

5252

5353
def no_executables_error(request):
54-
return render_to_response('codespeed/nodata.html', {
54+
return render(request, 'codespeed/nodata.html', {
5555
'message': 'There needs to be at least one executable'
5656
})
5757

5858

5959
def no_data_found(request):
60-
return render_to_response('codespeed/nodata.html', {
60+
return render(request, 'codespeed/nodata.html', {
6161
'message': 'No data found'
6262
})
6363

@@ -319,7 +319,7 @@ def comparison(request):
319319
settings.CHART_ORIENTATION == 'horizontal'):
320320
selecteddirection = True
321321

322-
return render_to_response('codespeed/comparison.html', {
322+
return render(request, 'codespeed/comparison.html', {
323323
'checkedexecutables': checkedexecutables,
324324
'checkedbenchmarks': checkedbenchmarks,
325325
'checkedenviros': checkedenviros,
@@ -633,7 +633,7 @@ def timeline(request):
633633
for proj in Project.objects.filter(track=True):
634634
executables[proj] = Executable.objects.filter(project=proj)
635635
use_median_bands = hasattr(settings, 'USE_MEDIAN_BANDS') and settings.USE_MEDIAN_BANDS
636-
return render_to_response('codespeed/timeline.html', {
636+
return render(request, 'codespeed/timeline.html', {
637637
'pagedesc': pagedesc,
638638
'checkedexecutables': checkedexecutables,
639639
'defaultbaseline': defaultbaseline,
@@ -717,7 +717,7 @@ def getchangestable(request):
717717
'<p class="errormessage">No results for this '
718718
'parameters</p>')
719719

720-
return render_to_response('codespeed/changes_data.html', {
720+
return render(request, 'codespeed/changes_data.html', {
721721
'tablelist': tablelist,
722722
'trendconfig': trendconfig,
723723
'rev': selectedrev,
@@ -823,7 +823,7 @@ def changes(request):
823823

824824
pagedesc = "Report of %s performance changes for commit %s on branch %s" % \
825825
(defaultexecutable, selectedrevision.commitid, selectedrevision.branch)
826-
return render_to_response('codespeed/changes.html', {
826+
return render(request, 'codespeed/changes.html', {
827827
'pagedesc': pagedesc,
828828
'defaultenvironment': defaultenv,
829829
'defaultexecutable': defaultexecutable,
@@ -850,7 +850,7 @@ def reports(request):
850850
colorcode__in=('red', 'green')
851851
).order_by('-revision__date')[:10]
852852

853-
return render_to_response('codespeed/reports.html', context)
853+
return render(request, 'codespeed/reports.html', context)
854854

855855

856856
@require_GET
@@ -895,7 +895,8 @@ def displaylogs(request):
895895
for log in logs:
896896
log['commit_browse_url'] = project.commit_browsing_url.format(**log)
897897

898-
return render_to_response(
898+
return render(
899+
request,
899900
'codespeed/changes_logs.html',
900901
{
901902
'error': error, 'logs': logs,

deploy-requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
-r requirements.txt
2-
psycopg2==2.9.3
3-
gunicorn==20.1.0
2+
psycopg-binary==3.1.17
3+
gunicorn==21.2.0

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Django>=1.11,<2.2
1+
django<4
22
isodate==0.6.1
33
matplotlib<3.8

speed_pypy/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
}
2626
}
2727

28+
DEFAULT_AUTO_FIELD='django.db.models.AutoField'
29+
2830
TIME_ZONE = 'America/Chicago'
2931

3032
LANGUAGE_CODE = 'en-us'
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{% ifequal obj.colorcode "red" %}Performance regressed: {% else %}
2-
{% ifequal obj.colorcode "green" %}Performance improved: {% else %}
3-
{% ifequal obj.colorcode "yellow" %}Trend regressed: {% else %}
1+
{% if obj.colorcode == "red" %}Performance regressed: {% else %}
2+
{% if obj.colorcode == "green" %}Performance improved: {% else %}
3+
{% if obj.colorcode == "yellow" %}Trend regressed: {% else %}
44
No significant changes.
5-
{% endifequal %}
6-
{% endifequal %}
7-
{% endifequal %}
5+
{% endif %}
6+
{% endif %}
7+
{% endif %}
88
{{ obj.summary }}

0 commit comments

Comments
 (0)