Skip to content

Commit

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

* Include namespace in admin urls

* Specify on_delete for models

* Remove level attempt model

* Fix test names

* Add test for on_delete

* Specify Django 2.0

* Use user attributes instead of function

* Try specifying Django 2.0 in Cypress

* Try installing local branches of other repos in cypress

* Dummy commit

* Simplify admin urls + Black

* Fix urls + fix tests

* Install local branches on Travis

* Install Django in Cypress

* Remove old unused view

* Update to Django 2.2 and upgrade dependencies

* Update actions to install local branches

* Install RR before portal

* Improve model tests

* Add test worksheet to other games
  • Loading branch information
faucomte97 committed Nov 23, 2020
1 parent 4244155 commit 2489966
Show file tree
Hide file tree
Showing 28 changed files with 327 additions and 900 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
run: |
pip install pipenv
pipenv install --dev --system
pip install -U git+https://github.com/ocadotechnology/rapid-router@django_2_0_test
pip install -U git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade
pip install -U "git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade#egg=cfl-common&subdirectory=cfl_common"
cd game_frontend
yarn --frozen-lockfile
- name: Run Javascript tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
run: |
pip install pipenv
pipenv install --dev --system
pip install -U git+https://github.com/ocadotechnology/rapid-router@django_2_0_test
pip install -U git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade
pip install -U "git+https://github.com/ocadotechnology/codeforlife-portal@django_2_upgrade#egg=cfl-common&subdirectory=cfl_common"
cd game_frontend
yarn install
- name: Build project and run server
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- nvm use 12
install:
- pipenv install --dev --system
- pip install --upgrade git+https://github.com/ocadotechnology/codeforlife-portal@django_2_0_test
- pip install --upgrade git+https://github.com/ocadotechnology/rapid-router@django_2_0_test
- pip install --upgrade "git+https://github.com/ocadotechnology/codeforlife-portal@django_2_0_test#egg=cfl-common&subdirectory=cfl_common"
- pushd game_frontend
- yarn --frozen-lockfile
- node djangoBundler.js
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name = "pypi"

[dev-packages]
pytest = "*"
pytest-django = ">=3.7.0, <3.8.0"
pytest-django = "==4.1.0"
pytest-pythonpath = "*"
codeforlife-portal = "*"
#codeforlife-portal = "*"
pytest-cov = "*"

[packages]
Expand Down
835 changes: 68 additions & 767 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions aimmo-game/tests/test_simulation/mock_communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ def __init__(self):
async def get_game_metadata(self):
return self.data

def mark_game_complete(self):
return {}

def patch_game(self, data):
return data

Expand Down
14 changes: 12 additions & 2 deletions aimmo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ class Migration(migrations.Migration):
primary_key=True,
),
),
("player", models.ForeignKey(to=settings.AUTH_USER_MODEL)),
(
"player",
models.ForeignKey(
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
),
),
],
),
migrations.CreateModel(
Expand All @@ -38,7 +43,12 @@ class Migration(migrations.Migration):
),
),
("code", models.TextField()),
("user", models.OneToOneField(to=settings.AUTH_USER_MODEL)),
(
"user",
models.OneToOneField(
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
),
),
],
),
]
9 changes: 7 additions & 2 deletions aimmo/migrations/0003_auto_20160802_1418.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,22 @@ class Migration(migrations.Migration):
related_name="owned_games",
to=settings.AUTH_USER_MODEL,
null=True,
on_delete=models.SET_NULL,
),
),
],
),
migrations.AddField(
model_name="avatar", name="game", field=models.ForeignKey(to="aimmo.Game")
model_name="avatar",
name="game",
field=models.ForeignKey(to="aimmo.Game", on_delete=models.CASCADE),
),
migrations.AddField(
model_name="avatar",
name="owner",
field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
field=models.ForeignKey(
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
),
),
migrations.AlterUniqueTogether(
name="avatar", unique_together=set([("owner", "game")])
Expand Down
8 changes: 6 additions & 2 deletions aimmo/migrations/0005_auto_20160808_1545.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Migration(migrations.Migration):
blank=True,
to=settings.AUTH_USER_MODEL,
null=True,
on_delete=models.SET_NULL,
),
),
migrations.AlterField(
Expand All @@ -60,17 +61,20 @@ class Migration(migrations.Migration):
blank=True,
to=settings.AUTH_USER_MODEL,
null=True,
on_delete=models.SET_NULL,
),
),
migrations.AddField(
model_name="levelattempt",
name="game",
field=models.OneToOneField(to="aimmo.Game"),
field=models.OneToOneField(to="aimmo.Game", on_delete=models.CASCADE),
),
migrations.AddField(
model_name="levelattempt",
name="user",
field=models.ForeignKey(to=settings.AUTH_USER_MODEL),
field=models.ForeignKey(
to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE
),
),
migrations.AlterUniqueTogether(
name="levelattempt", unique_together=set([("level_number", "user")])
Expand Down
22 changes: 13 additions & 9 deletions aimmo/migrations/0012_auto_20200302_1310.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@

class Migration(migrations.Migration):
dependencies = [
('aimmo', '0011_reset_game_tokens'),
("aimmo", "0011_reset_game_tokens"),
]

operations = [
migrations.AlterField(
model_name='game',
name='generator',
model_name="game",
name="generator",
field=models.CharField(
choices=[('Main', 'Open World'), ('Level1', 'Level 1')], default='Main',
max_length=20),
choices=[("Main", "Open World"), ("Level1", "Level 1")],
default="Main",
max_length=20,
),
),
migrations.AlterField(
model_name='game',
name='status',
model_name="game",
name="status",
field=models.CharField(
choices=[('r', 'running'), ('s', 'stopped'), ('p', 'paused')],
default='r', max_length=1),
choices=[("r", "running"), ("s", "stopped"), ("p", "paused")],
default="r",
max_length=1,
),
),
]
32 changes: 26 additions & 6 deletions aimmo/migrations/0014_add_worksheet_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,37 @@
class Migration(migrations.Migration):

dependencies = [
('aimmo', '0013_alter_game_can_play'),
("aimmo", "0013_alter_game_can_play"),
]

operations = [
migrations.CreateModel(
name='Worksheet',
name="Worksheet",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('era', models.PositiveSmallIntegerField(choices=[(1, 'future'), (2, 'ancient'), (3, 'modern day'), (4, 'prehistoric'), (5, 'broken future')], default=1)),
('starter_code', models.TextField()),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(max_length=100)),
(
"era",
models.PositiveSmallIntegerField(
choices=[
(1, "future"),
(2, "ancient"),
(3, "modern day"),
(4, "prehistoric"),
(5, "broken future"),
],
default=1,
),
),
("starter_code", models.TextField()),
],
),
]
13 changes: 9 additions & 4 deletions aimmo/migrations/0015_game_worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@
class Migration(migrations.Migration):

dependencies = [
('aimmo', '0014_add_worksheet_model'),
("aimmo", "0014_add_worksheet_model"),
]

operations = [
migrations.AddField(
model_name='game',
name='worksheet',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='aimmo.Worksheet'),
model_name="game",
name="worksheet",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
to="aimmo.Worksheet",
),
),
]
16 changes: 11 additions & 5 deletions aimmo/migrations/0016_game_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0001_initial'),
('aimmo', '0015_game_worksheet'),
("common", "0001_initial"),
("aimmo", "0015_game_worksheet"),
]

operations = [
migrations.AddField(
model_name='game',
name='game_class',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='games_for_class', to='common.Class'),
model_name="game",
name="game_class",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="games_for_class",
to="common.Class",
),
),
]
29 changes: 19 additions & 10 deletions aimmo/migrations/0019_game_has_worksheet_and_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,32 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0001_initial'),
('aimmo', '0018_set_worksheet_2_as_default_for_games'),
("common", "0001_initial"),
("aimmo", "0018_set_worksheet_2_as_default_for_games"),
]

operations = [
migrations.AlterField(
model_name='game',
name='game_class',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='games_for_class', to='common.Class', verbose_name='Class'),
model_name="game",
name="game_class",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="games_for_class",
to="common.Class",
verbose_name="Class",
),
),
migrations.AlterField(
model_name='game',
name='worksheet',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='aimmo.Worksheet'),
model_name="game",
name="worksheet",
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT, to="aimmo.Worksheet"
),
),
migrations.AlterUniqueTogether(
name='game',
unique_together=set([('game_class', 'worksheet')]),
name="game",
unique_together=set([("game_class", "worksheet")]),
),
]
10 changes: 5 additions & 5 deletions aimmo/migrations/0021_add_pdf_names_to_worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
class Migration(migrations.Migration):

dependencies = [
('aimmo', '0020_add_info_to_worksheet'),
("aimmo", "0020_add_info_to_worksheet"),
]

operations = [
migrations.AddField(
model_name='worksheet',
name='student_pdf_name',
model_name="worksheet",
name="student_pdf_name",
field=models.CharField(blank=True, max_length=255),
),
migrations.AddField(
model_name='worksheet',
name='teacher_pdf_name',
model_name="worksheet",
name="teacher_pdf_name",
field=models.CharField(blank=True, max_length=255),
),
]
28 changes: 28 additions & 0 deletions aimmo/migrations/0023_remove_level_attempt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.0 on 2020-10-28 17:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('aimmo', '0022_allow_games_to_have_no_name'),
]

operations = [
migrations.AlterUniqueTogether(
name='levelattempt',
unique_together=set(),
),
migrations.RemoveField(
model_name='levelattempt',
name='game',
),
migrations.RemoveField(
model_name='levelattempt',
name='user',
),
migrations.DeleteModel(
name='LevelAttempt',
),
]
Loading

0 comments on commit 2489966

Please sign in to comment.