Skip to content

Commit 4b7608a

Browse files
authored
feat!: Django 4 (#1748)
* feat: Upgrade to Django 4 * Install latest portal
1 parent 3aa339d commit 4b7608a

File tree

9 files changed

+612
-863
lines changed

9 files changed

+612
-863
lines changed

Pipfile

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@ verify_ssl = true
44
name = "pypi"
55

66
[packages]
7-
django-import-export = "*"
7+
cfl-common = ">=8.0.0"
88
ipython = "*"
99
rapid-router = {path = ".", editable = true}
1010

1111
[dev-packages]
1212
black = "*"
13-
codeforlife-portal = "*"
14-
django-import-export = "*"
15-
django-selenium-clean = "==1.0.0"
16-
django-test-migrations = "==1.2.0"
13+
codeforlife-portal = ">=8.0.0"
14+
django-selenium-clean = "==1.0.1"
15+
django-test-migrations = "==1.4.0"
1716
importlib-metadata = "<5" # Using version 5 causes an issue when trying to run pytest. Not sure why, linked to: https://stackoverflow.com/questions/73929564/entrypoints-object-has-no-attribute-get-digital-ocean
1817
isort = "*"
1918
pytest = "==8.*"
20-
pytest-django = "==4.5.2"
19+
pytest-django = "==4.8.0"
2120
pytest-order = "*"
2221
pytest-xdist = "*"
2322
selenium = "==4.9.0"

Pipfile.lock

+524-750
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example_project/urls.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from django.conf.urls import include, url
21
from django.contrib import admin
3-
from django.urls import path
2+
from django.urls import include, path, re_path
43
from portal import urls as portal_urls
54

65
from game import urls as game_urls
@@ -9,8 +8,8 @@
98
admin.autodiscover()
109

1110
urlpatterns = [
12-
url(r"^", include(portal_urls)),
11+
re_path(r"^", include(portal_urls)),
1312
path("administration/", admin.site.urls),
14-
url(r"^rapidrouter/", include(game_urls)),
15-
url(r"^pythonden/", include(python_den_urls)),
13+
re_path(r"^rapidrouter/", include(game_urls)),
14+
re_path(r"^pythonden/", include(python_den_urls)),
1615
]

game/end_to_end_tests/selenium_test_case.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,7 @@
66
see more information here: https://github.com/jazzband/django-pipeline/issues/593
77
"""
88

9-
from django.core.servers.basehttp import WSGIServer
10-
from django.test.testcases import (
11-
LiveServerTestCase,
12-
LiveServerThread,
13-
QuietWSGIRequestHandler,
14-
)
9+
from django.contrib.staticfiles.testing import LiveServerTestCase
1510
from django_selenium_clean import SeleniumTestCase
1611

17-
18-
class NonThreadedLiveServerThread(LiveServerThread):
19-
"""
20-
Replaces ThreadedWSGIServer with WSGIServer as the threaded one doesn't close the DB connections properly, thus
21-
triggering random "DB table locked" errors.
22-
"""
23-
24-
def _create_server(self):
25-
return WSGIServer(
26-
(self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False
27-
)
28-
29-
3012
SeleniumTestCase.__bases__ = (LiveServerTestCase,)
31-
SeleniumTestCase.server_thread_class = NonThreadedLiveServerThread

game/python_den_urls.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
from django.conf.urls import url
1+
from django.urls import re_path
22

33
from game.views.level import play_default_python_level, start_python_episode
44
from game.views.level_selection import python_levels
55
from game.views.scoreboard import python_scoreboard
66

77
urlpatterns = [
8-
url(r"^$", python_levels, name="python_levels"),
9-
url(
8+
re_path(r"^$", python_levels, name="python_levels"),
9+
re_path(
1010
r"^(?P<level_name>[A-Z0-9]+)/$",
1111
play_default_python_level,
1212
name="play_python_default_level",
1313
),
14-
url(
14+
re_path(
1515
r"^episode/(?P<episodeId>[0-9]+)/$",
1616
start_python_episode,
1717
name="start_python_episode",
1818
),
19-
url(r"^scoreboard/$", python_scoreboard, name="python_scoreboard"),
19+
re_path(r"^scoreboard/$", python_scoreboard, name="python_scoreboard"),
2020
]

game/templates/game/scoreboard.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,22 @@ <h4 class="text-center" id="scoreboardTitle">Scoreboard</h4>
171171
</tr>
172172
</thead>
173173
{% for student in student_data %}
174-
{% ifnotequal student.name user.first_name %}
174+
{% if student.name != user.first_name %}
175175
<tr>
176176
{% else %}
177177
<tr class="current-student">
178-
{% endifnotequal %}
178+
{% endif %}
179179
<td class="fixed-width">{{ student.class_field }}</td>
180180
<td class="fixed-width">{{ student.name }}</td>
181181
<td>{{ student.completed }}</td>
182182
<td>{{ student.total_time }}</td>
183183
{% for level_id, level_score in student.level_scores.items %}
184184
{% if level_score.full_score %}
185-
{% ifnotequal student.name user.first_name %}
185+
{% if student.name != user.first_name %}
186186
<td class="text-center scoreboard--completed">
187187
{% else %}
188188
<td class="text-center scoreboard--completed-secondary">
189-
{% endifnotequal %}
189+
{% endif %}
190190
<div title="{{ level_score.score }}" class="d-flex justify-content-center">
191191
<span class="iconify" data-icon="mdi:star"></span>
192192
</div>
@@ -246,20 +246,20 @@ <h5>Shared levels</h5>
246246
</tr>
247247
</thead>
248248
{% for student in shared_student_data %}
249-
{% ifnotequal student.name user.first_name %}
249+
{% if student.name != user.first_name %}
250250
<tr>
251251
{% else %}
252252
<tr class="current-student">
253-
{% endifnotequal %}
253+
{% endif %}
254254
<td class="fixed-width">{{ student.class_field }}</td>
255255
<td class="fixed-width">{{ student.name }}</td>
256256
{% for level_id, level_score in student.level_scores.items %}
257257
{% if level_score.full_score %}
258-
{% ifnotequal student.name user.first_name %}
258+
{% if student.name != user.first_name %}
259259
<td class="text-center scoreboard--completed">
260260
{% else %}
261261
<td class="text-center scoreboard--completed-secondary">
262-
{% endifnotequal %}
262+
{% endif %}
263263
<div title="{{ level_score.score }}" class="d-flex justify-content-center">
264264
<span class="iconify" data-icon="mdi:star"></span>
265265
</div>

game/theme.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from builtins import object
66
from rest_framework.reverse import reverse
7-
from django.utils.translation import ugettext
7+
from django.utils.translation import gettext
88

99

1010
class Theme(object):
@@ -20,31 +20,31 @@ def __init__(self, pk, name, text, background, border, selected):
2020
THEME_DATA = {
2121
"grass": Theme(
2222
name="grass",
23-
text=ugettext("Grass"),
23+
text=gettext("Grass"),
2424
selected="#bce369",
2525
background="#a0c53a",
2626
border="#70961f",
2727
pk=1,
2828
),
2929
"snow": Theme(
3030
name="snow",
31-
text=ugettext("Snow"),
31+
text=gettext("Snow"),
3232
selected="#b3deff",
3333
background="#eef7ff",
3434
border="#83c9fe",
3535
pk=2,
3636
),
3737
"farm": Theme(
3838
name="farm",
39-
text=ugettext("Farm"),
39+
text=gettext("Farm"),
4040
selected="#bce369",
4141
background="#a0c53a",
4242
border="#70961f",
4343
pk=3,
4444
),
4545
"city": Theme(
4646
name="city",
47-
text=ugettext("City"),
47+
text=gettext("City"),
4848
selected="#C1C1C1",
4949
background="#969696",
5050
border="#686868",

0 commit comments

Comments
 (0)