Skip to content

Commit

Permalink
fix: tidy code
Browse files Browse the repository at this point in the history
  • Loading branch information
evemartin committed Apr 10, 2024
1 parent 3e472f3 commit b8947e9
Show file tree
Hide file tree
Showing 39 changed files with 214 additions and 174 deletions.
7 changes: 3 additions & 4 deletions cfl_common/common/helpers/data_migration_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def load_data_from_file(file_name) -> Callable:
For use with migrations.RunPython
Args:
file_name (str): The name of the file containing the data you want to load. Include `.json` at the end. The file must be in the fixtures directory.
file_name (str): The name of the file containing the data you want to load. Include `.json` at the end.
The file must be in the fixtures directory.
"""
absolute_file_path = Path(__file__).resolve().parent.parent / "fixtures" / file_name

Expand All @@ -26,9 +27,7 @@ def _get_model(model_identifier):
try:
return apps.get_model(model_identifier)
except (LookupError, TypeError):
raise base.DeserializationError(
"Invalid model identifier: '%s'" % model_identifier
)
raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier)

# Replace the _get_model() function on the module, so loaddata can utilize it.
python._get_model = _get_model
Expand Down
2 changes: 1 addition & 1 deletion cfl_common/common/helpers/generators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hashlib
import random
import string
import hashlib
from builtins import range, str
from uuid import uuid4

Expand Down
1 change: 0 additions & 1 deletion cfl_common/common/mail.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import typing as t
from dataclasses import dataclass

Expand Down
4 changes: 1 addition & 3 deletions cfl_common/common/migrations/0002_emailverification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ class Migration(migrations.Migration):
("token", models.CharField(max_length=30)),
(
"email",
models.CharField(
blank=True, default=None, max_length=200, null=True
),
models.CharField(blank=True, default=None, max_length=200, null=True),
),
("expiry", models.DateTimeField()),
("verified", models.BooleanField(default=False)),
Expand Down
6 changes: 1 addition & 5 deletions cfl_common/common/migrations/0005_add_worksheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ class Migration(migrations.Migration):
("aimmo", "0020_add_info_to_worksheet"),
]

operations = [
migrations.RunPython(
migrations.RunPython.noop, reverse_code=migrations.RunPython.noop
)
]
operations = [migrations.RunPython(migrations.RunPython.noop, reverse_code=migrations.RunPython.noop)]
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ class Migration(migrations.Migration):
("aimmo", "0021_add_pdf_names_to_worksheet"),
]

operations = [
migrations.RunPython(
migrations.RunPython.noop, reverse_code=migrations.RunPython.noop
)
]
operations = [migrations.RunPython(migrations.RunPython.noop, reverse_code=migrations.RunPython.noop)]
6 changes: 1 addition & 5 deletions cfl_common/common/migrations/0008_unlock_worksheet_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ class Migration(migrations.Migration):
("common", "0007_add_pdf_names_to_first_two_worksheets"),
]

operations = [
migrations.RunPython(
migrations.RunPython.noop, reverse_code=migrations.RunPython.noop
)
]
operations = [migrations.RunPython(migrations.RunPython.noop, reverse_code=migrations.RunPython.noop)]
10 changes: 2 additions & 8 deletions cfl_common/common/migrations/0017_copy_email_to_username.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

def copy_email_to_username(apps, schema):
Student = apps.get_model("common", "Student")
independent_students = Student.objects.filter(
class_field__isnull=True, new_user__is_active=True
)
independent_students = Student.objects.filter(class_field__isnull=True, new_user__is_active=True)
for student in independent_students:
student.new_user.username = student.new_user.email
student.new_user.save()
Expand All @@ -17,8 +15,4 @@ class Migration(migrations.Migration):
("common", "0016_joinreleasestudent"),
]

operations = [
migrations.RunPython(
code=copy_email_to_username, reverse_code=migrations.RunPython.noop
)
]
operations = [migrations.RunPython(code=copy_email_to_username, reverse_code=migrations.RunPython.noop)]
14 changes: 7 additions & 7 deletions cfl_common/common/migrations/0021_school_is_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0020_class_is_active_and_null_access_code'),
("common", "0020_class_is_active_and_null_access_code"),
]

operations = [
migrations.AddField(
model_name='school',
name='is_active',
model_name="school",
name="is_active",
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='school',
name='postcode',
model_name="school",
name="postcode",
field=models.CharField(max_length=10, null=True),
),
migrations.AlterField(
model_name='school',
name='town',
model_name="school",
name="town",
field=models.CharField(max_length=200, null=True),
),
]
18 changes: 9 additions & 9 deletions cfl_common/common/migrations/0022_school_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0021_school_is_active'),
("common", "0021_school_is_active"),
]

operations = [
migrations.RemoveField(
model_name='school',
name='latitude',
model_name="school",
name="latitude",
),
migrations.RemoveField(
model_name='school',
name='longitude',
model_name="school",
name="longitude",
),
migrations.RemoveField(
model_name='school',
name='town',
model_name="school",
name="town",
),
migrations.RemoveField(
model_name='userprofile',
name='can_view_aggregated_data',
model_name="userprofile",
name="can_view_aggregated_data",
),
]
8 changes: 4 additions & 4 deletions cfl_common/common/migrations/0023_userprofile_aimmo_badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0022_school_cleanup'),
("common", "0022_school_cleanup"),
]

operations = [
migrations.AlterModelOptions(
name='school',
name="school",
options={},
),
migrations.AddField(
model_name='userprofile',
name='aimmo_badges',
model_name="userprofile",
name="aimmo_badges",
field=models.CharField(blank=True, max_length=200, null=True),
),
]
42 changes: 29 additions & 13 deletions cfl_common/common/migrations/0025_schoolteacherinvitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,40 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0024_teacher_invited_by'),
("common", "0024_teacher_invited_by"),
]

operations = [
migrations.CreateModel(
name='SchoolTeacherInvitation',
name="SchoolTeacherInvitation",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('token', models.CharField(max_length=32)),
('invited_teacher_first_name', models.CharField(max_length=150)),
('invited_teacher_last_name', models.CharField(max_length=150)),
('invited_teacher_email', models.EmailField(max_length=254)),
('invited_teacher_is_admin', models.BooleanField(default=False)),
('expiry', models.DateTimeField()),
('creation_time', models.DateTimeField(default=django.utils.timezone.now, null=True)),
('is_active', models.BooleanField(default=True)),
('from_teacher', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='school_invitations', to='common.teacher')),
('school', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teacher_invitations', to='common.school')),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("token", models.CharField(max_length=32)),
("invited_teacher_first_name", models.CharField(max_length=150)),
("invited_teacher_last_name", models.CharField(max_length=150)),
("invited_teacher_email", models.EmailField(max_length=254)),
("invited_teacher_is_admin", models.BooleanField(default=False)),
("expiry", models.DateTimeField()),
("creation_time", models.DateTimeField(default=django.utils.timezone.now, null=True)),
("is_active", models.BooleanField(default=True)),
(
"from_teacher",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="school_invitations",
to="common.teacher",
),
),
(
"school",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="teacher_invitations",
to="common.school",
),
),
],
),
]
10 changes: 5 additions & 5 deletions cfl_common/common/migrations/0026_teacher_remove_join_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0025_schoolteacherinvitation'),
("common", "0025_schoolteacherinvitation"),
]

operations = [
migrations.RemoveField(
model_name='teacher',
name='pending_join_request',
model_name="teacher",
name="pending_join_request",
),
migrations.AlterField(
model_name='teacher',
name='blocked_time',
model_name="teacher",
name="blocked_time",
field=models.DateTimeField(blank=True, null=True),
),
]
14 changes: 10 additions & 4 deletions cfl_common/common/migrations/0027_class_created_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0026_teacher_remove_join_request'),
("common", "0026_teacher_remove_join_request"),
]

operations = [
migrations.AddField(
model_name='class',
name='created_by',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_classes', to='common.teacher'),
model_name="class",
name="created_by",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_classes",
to="common.teacher",
),
),
]
10 changes: 5 additions & 5 deletions cfl_common/common/migrations/0028_coding_club_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0027_class_created_by'),
("common", "0027_class_created_by"),
]

operations = [
migrations.AddField(
model_name='dailyactivity',
name='primary_coding_club_downloads',
model_name="dailyactivity",
name="primary_coding_club_downloads",
field=models.PositiveIntegerField(default=0),
),
migrations.AddField(
model_name='dailyactivity',
name='python_coding_club_downloads',
model_name="dailyactivity",
name="python_coding_club_downloads",
field=models.PositiveIntegerField(default=0),
),
]
12 changes: 6 additions & 6 deletions cfl_common/common/migrations/0029_dynamicelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
class Migration(migrations.Migration):

dependencies = [
('common', '0028_coding_club_downloads'),
("common", "0028_coding_club_downloads"),
]

operations = [
migrations.CreateModel(
name='DynamicElement',
name="DynamicElement",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=64, unique=True, editable=False)),
('active', models.BooleanField(default=False)),
('text', models.TextField(blank=True, null=True)),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=64, unique=True, editable=False)),
("active", models.BooleanField(default=False)),
("text", models.TextField(blank=True, null=True)),
],
),
]
4 changes: 1 addition & 3 deletions cfl_common/common/migrations/0030_add_maintenance_banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ class Migration(migrations.Migration):

dependencies = [("common", "0029_dynamicelement")]

operations = [
migrations.RunPython(add_maintenance_banner, remove_maintenance_banner)
]
operations = [migrations.RunPython(add_maintenance_banner, remove_maintenance_banner)]
Loading

0 comments on commit b8947e9

Please sign in to comment.