Skip to content

Commit

Permalink
feat: Upgrade to Django 2.2 (#1132)
Browse files Browse the repository at this point in the history
* Upgrade Django to 2.0

* Upgrade pytest to fix pipenv conflicts

* Include namespace in admin urls

* Use class based JavaScript catalog

* Replace core.urlresolvers by urls

* Use user properties instead of functions

* Specify on_delete for models

* Merge branch 'master' into django_2_0_test

# Conflicts:
#	Pipfile
#	Pipfile.lock
#	game/__init__.py

* Replace urls.resolvers with urls pt 2

* Add test for on_delete

* Specify Django 2.0

* Simplify admin urls + Black

* Fix admin URL

* Fix tests + upgrade

* Install local common in travis

* Merge branch 'master' into django_2_0_test

* Upgrade dependencies

* Improve model tests

* Install local portal and common

* Also install local aimmo

* Fix RR migration tests

* Install correct upgrade branches

* Install autoconfig
  • Loading branch information
faucomte97 authored Nov 23, 2020
1 parent 7f69153 commit aacebbc
Show file tree
Hide file tree
Showing 35 changed files with 492 additions and 548 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ jobs:
pip install pipenv
pip install pytest-cov
pipenv install --dev --system
pip install -U git+https://github.com/ocadotechnology/codeforlife-portal.git#egg=codeforlife-portal #TODO: Remove as part of #688
pip install django-autoconfig
pip install -U git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade #TODO: Remove as part of #688
pip install -U git+https://github.com/ocadotechnology/aimmo@django_2_upgrade
pip install -U "git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade#egg=cfl-common&subdirectory=cfl_common"
- name: Collect static
run: python example_project/manage.py collectstatic --noinput
- name: Run tests
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- pip install -U setuptools
- pip install pipenv
- pipenv install --dev --system
- pip install -U git+https://github.com/ocadotechnology/codeforlife-portal.git#egg=codeforlife-portal #TODO: Remove as part of #688
- pip install --upgrade git+https://github.com/ocadotechnology/codeforlife-portal@django_2_0_test
- pip install --upgrade git+https://github.com/ocadotechnology/aimmo@django_2_0_test
- pip install --upgrade "git+https://github.com/ocadotechnology/codeforlife-portal@django_2_0_test#egg=cfl-common&subdirectory=cfl_common"
- pip install crowdin-cli-py
- pip install selenium==3.141.0
- pip install pytest-cov
Expand All @@ -48,7 +50,7 @@ jobs:
- pip install -U setuptools
- pip install pipenv
- pipenv install --dev --system
- pip install git+https://github.com/ocadotechnology/codeforlife-portal.git#egg=codeforlife-portal #TODO: Remove as part of #688
- pip install --upgrade git+https://github.com/ocadotechnology/codeforlife-portal@django_2_0_test
- pip install crowdin-cli-py
script:
- mkdir -p game/locale
Expand Down
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ rapid-router = {path = ".",editable = true}

[dev-packages]
django-selenium-clean = "==0.3.2"
django-test-migrations = "==1.0.0"
selenium = "==3.141.0"
pytest-django = ">=3.5.1<3.6.0"
pytest = "<6"
pytest-django = "==4.1.0"
pytest = "==6.*"

[requires]
python_version = "3.6"
python_version = "3.6.7"
317 changes: 55 additions & 262 deletions Pipfile.lock

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions example_project/example_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from aimmo import urls as aimmo_urls
from django.conf.urls import include, url
from django.contrib import admin
from game import urls as game_urls
from django.urls import path
from portal import urls as portal_urls

from game import urls as game_urls

admin.autodiscover()

urlpatterns = [
url(r'^', include(portal_urls)),
url(r'^administration/', include(admin.site.urls)),
url(r'^rapidrouter/', include(game_urls)),
url(r'^aimmo/', include(aimmo_urls)),
url(r"^", include(portal_urls)),
path("administration/", admin.site.urls),
url(r"^rapidrouter/", include(game_urls)),
url(r"^aimmo/", include(aimmo_urls)),
]
9 changes: 4 additions & 5 deletions game/end_to_end_tests/base_game_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,18 @@
# identified as the original program.
import os
import socket
import time
from builtins import str

import time
from common.models import UserProfile
from common.tests.utils.classes import create_class_directly
from common.tests.utils.organisation import create_organisation_directly
from common.tests.utils.student import create_school_student_directly
from common.tests.utils.teacher import signup_teacher_directly
from django.core.urlresolvers import reverse

from game.models import Workspace
from django.urls import reverse
from portal.tests.pageObjects.portal.home_page import HomePage
from portal.tests.utils.organisation import create_organisation_directly

from game.models import Workspace
from . import custom_handler
from .editor_page import EditorPage
from .game_page import GamePage
Expand Down
2 changes: 1 addition & 1 deletion game/end_to_end_tests/game_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import os
import time

from django.core.urlresolvers import reverse
from django.urls import reverse
from hamcrest import assert_that, equal_to, contains_string, ends_with
from portal.tests.pageObjects.portal.base_page import BasePage
from selenium.common.exceptions import TimeoutException
Expand Down
4 changes: 2 additions & 2 deletions game/level_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def add_related_fields(levels):


def levels_shared_with(user):
if user.is_anonymous():
if user.is_anonymous:
return []

shared_levels = user.shared
Expand All @@ -78,7 +78,7 @@ def levels_shared_with(user):


def levels_owned_by(user):
if user.is_anonymous():
if user.is_anonymous:
return []

levels = user.userprofile.levels
Expand Down
155 changes: 101 additions & 54 deletions game/migrations/0001_squashed_0025_levels_ordering_pt1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1713,60 +1713,70 @@ def add_episodes_1_to_6(apps, schema_editor):
)
episode6.save()

episode1.r_blocks = Block.objects.filter(
type__in=["turn_left", "turn_right", "move_forwards"]
episode1.r_blocks.set(
Block.objects.filter(type__in=["turn_left", "turn_right", "move_forwards"])
)

episode2.r_blocks = Block.objects.filter(
type__in=["turn_left", "turn_right", "move_forwards", "deliver"]
episode2.r_blocks.set(
Block.objects.filter(
type__in=["turn_left", "turn_right", "move_forwards", "deliver"]
)
)

episode3.r_blocks = Block.objects.filter(
type__in=["turn_left", "turn_right", "move_forwards", "controls_repeat"]
episode3.r_blocks.set(
Block.objects.filter(
type__in=["turn_left", "turn_right", "move_forwards", "controls_repeat"]
)
)

episode4.r_blocks = Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"at_destination",
"controls_repeat",
]
episode4.r_blocks.set(
Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"at_destination",
"controls_repeat",
]
)
)

episode5.r_blocks = Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"at_destination",
"controls_if",
"road_exists",
"dead_end",
"controls_repeat",
"turn_around",
]
episode5.r_blocks.set(
Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"at_destination",
"controls_if",
"road_exists",
"dead_end",
"controls_repeat",
"turn_around",
]
)
)

episode6.r_blocks = Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"controls_if",
"road_exists",
"at_destination",
"wait",
"controls_repeat",
"dead_end",
"turn_around",
"controls_repeat_while",
"traffic_light",
]
episode6.r_blocks.set(
Block.objects.filter(
type__in=[
"turn_left",
"turn_right",
"move_forwards",
"controls_repeat_until",
"controls_if",
"road_exists",
"at_destination",
"wait",
"controls_repeat",
"dead_end",
"turn_around",
"controls_repeat_while",
"traffic_light",
]
)
)

episode1.save()
Expand Down Expand Up @@ -4946,7 +4956,12 @@ class Migration(migrations.Migration):
("url", models.CharField(max_length=500)),
("width", models.IntegerField()),
("height", models.IntegerField()),
("theme", models.ForeignKey(related_name="decor", to="game.Theme")),
(
"theme",
models.ForeignKey(
related_name="decor", to="game.Theme", on_delete=models.CASCADE
),
),
],
),
migrations.CreateModel(
Expand Down Expand Up @@ -4978,10 +4993,20 @@ class Migration(migrations.Migration):
("blocklyEnabled", models.BooleanField(default=True)),
("pythonEnabled", models.BooleanField(default=True)),
("anonymous", models.BooleanField(default=False)),
("character", models.ForeignKey(default=1, to="game.Character")),
(
"character",
models.ForeignKey(
default=1, to="game.Character", on_delete=models.CASCADE
),
),
(
"next_level",
models.ForeignKey(default=None, to="game.Level", null=True),
models.ForeignKey(
default=None,
to="game.Level",
null=True,
on_delete=models.SET_NULL,
),
),
(
"owner",
Expand All @@ -4990,6 +5015,7 @@ class Migration(migrations.Migration):
blank=True,
to="portal.UserProfile",
null=True,
on_delete=models.CASCADE,
),
),
(
Expand All @@ -5004,7 +5030,11 @@ class Migration(migrations.Migration):
(
"theme",
models.ForeignKey(
default=None, blank=True, to="game.Theme", null=True
default=None,
blank=True,
to="game.Theme",
null=True,
on_delete=models.CASCADE,
),
),
],
Expand All @@ -5031,7 +5061,12 @@ class Migration(migrations.Migration):
("r_trafficLights", models.BooleanField(default=False)),
(
"next_episode",
models.ForeignKey(default=None, to="game.Episode", null=True),
models.ForeignKey(
default=None,
to="game.Episode",
null=True,
on_delete=models.SET_NULL,
),
),
(
"r_blocks",
Expand All @@ -5041,7 +5076,10 @@ class Migration(migrations.Migration):
),
("in_development", models.BooleanField(default=False)),
("r_random_levels_enabled", models.BooleanField(default=False)),
("first_level", models.ForeignKey(to="game.Level")),
(
"first_level",
models.ForeignKey(to="game.Level", on_delete=models.SET_NULL),
),
],
),
migrations.CreateModel(
Expand All @@ -5059,7 +5097,7 @@ class Migration(migrations.Migration):
("x", models.IntegerField()),
("y", models.IntegerField()),
("decorName", models.CharField(default="tree1", max_length=100)),
("level", models.ForeignKey(to="game.Level")),
("level", models.ForeignKey(to="game.Level", on_delete=models.CASCADE)),
],
),
migrations.CreateModel(
Expand All @@ -5083,6 +5121,7 @@ class Migration(migrations.Migration):
blank=True,
to="portal.UserProfile",
null=True,
on_delete=models.CASCADE,
),
),
("python_contents", models.TextField(default="")),
Expand All @@ -5101,8 +5140,8 @@ class Migration(migrations.Migration):
),
),
("number", models.PositiveIntegerField(default=None, null=True)),
("level", models.ForeignKey(to="game.Level")),
("type", models.ForeignKey(to="game.Block")),
("level", models.ForeignKey(to="game.Level", on_delete=models.CASCADE)),
("type", models.ForeignKey(to="game.Block", on_delete=models.CASCADE)),
],
),
migrations.CreateModel(
Expand All @@ -5122,14 +5161,22 @@ class Migration(migrations.Migration):
("score", models.FloatField(default=0, null=True)),
("workspace", models.TextField(default="")),
("python_workspace", models.TextField(default="")),
("level", models.ForeignKey(related_name="attempts", to="game.Level")),
(
"level",
models.ForeignKey(
related_name="attempts",
to="game.Level",
on_delete=models.CASCADE,
),
),
(
"student",
models.ForeignKey(
related_name="attempts",
blank=True,
to="portal.Student",
null=True,
on_delete=models.CASCADE,
),
),
],
Expand Down
6 changes: 5 additions & 1 deletion game/migrations/0040_auto_20150128_2019.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class Migration(migrations.Migration):
model_name="level",
name="episode",
field=models.ForeignKey(
default=None, blank=True, to="game.Episode", null=True
default=None,
blank=True,
to="game.Episode",
null=True,
on_delete=models.PROTECT,
),
preserve_default=False,
)
Expand Down
6 changes: 5 additions & 1 deletion game/migrations/0043_auto_20150615_1155.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ class Migration(migrations.Migration):
model_name="level",
name="episode",
field=models.ForeignKey(
default=None, blank=True, to="game.Episode", null=True
default=None,
blank=True,
to="game.Episode",
null=True,
on_delete=models.PROTECT,
),
),
]
Loading

0 comments on commit aacebbc

Please sign in to comment.