Skip to content

Commit

Permalink
feat!: Django 4 (#1748)
Browse files Browse the repository at this point in the history
* feat: Upgrade to Django 4

* Install latest portal
  • Loading branch information
faucomte97 authored Nov 8, 2024
1 parent 3aa339d commit 4b7608a
Show file tree
Hide file tree
Showing 9 changed files with 612 additions and 863 deletions.
11 changes: 5 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ verify_ssl = true
name = "pypi"

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

[dev-packages]
black = "*"
codeforlife-portal = "*"
django-import-export = "*"
django-selenium-clean = "==1.0.0"
django-test-migrations = "==1.2.0"
codeforlife-portal = ">=8.0.0"
django-selenium-clean = "==1.0.1"
django-test-migrations = "==1.4.0"
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
isort = "*"
pytest = "==8.*"
pytest-django = "==4.5.2"
pytest-django = "==4.8.0"
pytest-order = "*"
pytest-xdist = "*"
selenium = "==4.9.0"
Expand Down
1,274 changes: 524 additions & 750 deletions Pipfile.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions example_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import path
from django.urls import include, path, re_path
from portal import urls as portal_urls

from game import urls as game_urls
Expand All @@ -9,8 +8,8 @@
admin.autodiscover()

urlpatterns = [
url(r"^", include(portal_urls)),
re_path(r"^", include(portal_urls)),
path("administration/", admin.site.urls),
url(r"^rapidrouter/", include(game_urls)),
url(r"^pythonden/", include(python_den_urls)),
re_path(r"^rapidrouter/", include(game_urls)),
re_path(r"^pythonden/", include(python_den_urls)),
]
21 changes: 1 addition & 20 deletions game/end_to_end_tests/selenium_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@
see more information here: https://github.com/jazzband/django-pipeline/issues/593
"""

from django.core.servers.basehttp import WSGIServer
from django.test.testcases import (
LiveServerTestCase,
LiveServerThread,
QuietWSGIRequestHandler,
)
from django.contrib.staticfiles.testing import LiveServerTestCase
from django_selenium_clean import SeleniumTestCase


class NonThreadedLiveServerThread(LiveServerThread):
"""
Replaces ThreadedWSGIServer with WSGIServer as the threaded one doesn't close the DB connections properly, thus
triggering random "DB table locked" errors.
"""

def _create_server(self):
return WSGIServer(
(self.host, self.port), QuietWSGIRequestHandler, allow_reuse_address=False
)


SeleniumTestCase.__bases__ = (LiveServerTestCase,)
SeleniumTestCase.server_thread_class = NonThreadedLiveServerThread
10 changes: 5 additions & 5 deletions game/python_den_urls.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from django.conf.urls import url
from django.urls import re_path

from game.views.level import play_default_python_level, start_python_episode
from game.views.level_selection import python_levels
from game.views.scoreboard import python_scoreboard

urlpatterns = [
url(r"^$", python_levels, name="python_levels"),
url(
re_path(r"^$", python_levels, name="python_levels"),
re_path(
r"^(?P<level_name>[A-Z0-9]+)/$",
play_default_python_level,
name="play_python_default_level",
),
url(
re_path(
r"^episode/(?P<episodeId>[0-9]+)/$",
start_python_episode,
name="start_python_episode",
),
url(r"^scoreboard/$", python_scoreboard, name="python_scoreboard"),
re_path(r"^scoreboard/$", python_scoreboard, name="python_scoreboard"),
]
16 changes: 8 additions & 8 deletions game/templates/game/scoreboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,22 @@ <h4 class="text-center" id="scoreboardTitle">Scoreboard</h4>
</tr>
</thead>
{% for student in student_data %}
{% ifnotequal student.name user.first_name %}
{% if student.name != user.first_name %}
<tr>
{% else %}
<tr class="current-student">
{% endifnotequal %}
{% endif %}
<td class="fixed-width">{{ student.class_field }}</td>
<td class="fixed-width">{{ student.name }}</td>
<td>{{ student.completed }}</td>
<td>{{ student.total_time }}</td>
{% for level_id, level_score in student.level_scores.items %}
{% if level_score.full_score %}
{% ifnotequal student.name user.first_name %}
{% if student.name != user.first_name %}
<td class="text-center scoreboard--completed">
{% else %}
<td class="text-center scoreboard--completed-secondary">
{% endifnotequal %}
{% endif %}
<div title="{{ level_score.score }}" class="d-flex justify-content-center">
<span class="iconify" data-icon="mdi:star"></span>
</div>
Expand Down Expand Up @@ -246,20 +246,20 @@ <h5>Shared levels</h5>
</tr>
</thead>
{% for student in shared_student_data %}
{% ifnotequal student.name user.first_name %}
{% if student.name != user.first_name %}
<tr>
{% else %}
<tr class="current-student">
{% endifnotequal %}
{% endif %}
<td class="fixed-width">{{ student.class_field }}</td>
<td class="fixed-width">{{ student.name }}</td>
{% for level_id, level_score in student.level_scores.items %}
{% if level_score.full_score %}
{% ifnotequal student.name user.first_name %}
{% if student.name != user.first_name %}
<td class="text-center scoreboard--completed">
{% else %}
<td class="text-center scoreboard--completed-secondary">
{% endifnotequal %}
{% endif %}
<div title="{{ level_score.score }}" class="d-flex justify-content-center">
<span class="iconify" data-icon="mdi:star"></span>
</div>
Expand Down
10 changes: 5 additions & 5 deletions game/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from builtins import object
from rest_framework.reverse import reverse
from django.utils.translation import ugettext
from django.utils.translation import gettext


class Theme(object):
Expand All @@ -20,31 +20,31 @@ def __init__(self, pk, name, text, background, border, selected):
THEME_DATA = {
"grass": Theme(
name="grass",
text=ugettext("Grass"),
text=gettext("Grass"),
selected="#bce369",
background="#a0c53a",
border="#70961f",
pk=1,
),
"snow": Theme(
name="snow",
text=ugettext("Snow"),
text=gettext("Snow"),
selected="#b3deff",
background="#eef7ff",
border="#83c9fe",
pk=2,
),
"farm": Theme(
name="farm",
text=ugettext("Farm"),
text=gettext("Farm"),
selected="#bce369",
background="#a0c53a",
border="#70961f",
pk=3,
),
"city": Theme(
name="city",
text=ugettext("City"),
text=gettext("City"),
selected="#C1C1C1",
background="#969696",
border="#686868",
Expand Down
Loading

0 comments on commit 4b7608a

Please sign in to comment.