diff --git a/cfl_common/common/helpers/data_migration_loader.py b/cfl_common/common/helpers/data_migration_loader.py index f5cfbb2a2..8f00d433f 100644 --- a/cfl_common/common/helpers/data_migration_loader.py +++ b/cfl_common/common/helpers/data_migration_loader.py @@ -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 @@ -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 diff --git a/cfl_common/common/helpers/generators.py b/cfl_common/common/helpers/generators.py index e4506b64e..a890e0503 100644 --- a/cfl_common/common/helpers/generators.py +++ b/cfl_common/common/helpers/generators.py @@ -1,6 +1,6 @@ +import hashlib import random import string -import hashlib from builtins import range, str from uuid import uuid4 diff --git a/cfl_common/common/mail.py b/cfl_common/common/mail.py index 91cef7c96..b786b830a 100644 --- a/cfl_common/common/mail.py +++ b/cfl_common/common/mail.py @@ -1,4 +1,3 @@ -import os import typing as t from dataclasses import dataclass diff --git a/cfl_common/common/migrations/0002_emailverification.py b/cfl_common/common/migrations/0002_emailverification.py index 9c0c6751b..384a401a3 100644 --- a/cfl_common/common/migrations/0002_emailverification.py +++ b/cfl_common/common/migrations/0002_emailverification.py @@ -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)), diff --git a/cfl_common/common/migrations/0005_add_worksheets.py b/cfl_common/common/migrations/0005_add_worksheets.py index a0949a223..856fcc8f3 100644 --- a/cfl_common/common/migrations/0005_add_worksheets.py +++ b/cfl_common/common/migrations/0005_add_worksheets.py @@ -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)] diff --git a/cfl_common/common/migrations/0007_add_pdf_names_to_first_two_worksheets.py b/cfl_common/common/migrations/0007_add_pdf_names_to_first_two_worksheets.py index b582f33b8..7af0cde05 100644 --- a/cfl_common/common/migrations/0007_add_pdf_names_to_first_two_worksheets.py +++ b/cfl_common/common/migrations/0007_add_pdf_names_to_first_two_worksheets.py @@ -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)] diff --git a/cfl_common/common/migrations/0008_unlock_worksheet_3.py b/cfl_common/common/migrations/0008_unlock_worksheet_3.py index 82edfc6b2..ab96d3571 100644 --- a/cfl_common/common/migrations/0008_unlock_worksheet_3.py +++ b/cfl_common/common/migrations/0008_unlock_worksheet_3.py @@ -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)] diff --git a/cfl_common/common/migrations/0017_copy_email_to_username.py b/cfl_common/common/migrations/0017_copy_email_to_username.py index 9eb4f75fb..ec5dfd6a4 100644 --- a/cfl_common/common/migrations/0017_copy_email_to_username.py +++ b/cfl_common/common/migrations/0017_copy_email_to_username.py @@ -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() @@ -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)] diff --git a/cfl_common/common/migrations/0021_school_is_active.py b/cfl_common/common/migrations/0021_school_is_active.py index d4e867d7f..b19b3afc0 100644 --- a/cfl_common/common/migrations/0021_school_is_active.py +++ b/cfl_common/common/migrations/0021_school_is_active.py @@ -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), ), ] diff --git a/cfl_common/common/migrations/0022_school_cleanup.py b/cfl_common/common/migrations/0022_school_cleanup.py index 273b2aef7..7c25ab851 100644 --- a/cfl_common/common/migrations/0022_school_cleanup.py +++ b/cfl_common/common/migrations/0022_school_cleanup.py @@ -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", ), ] diff --git a/cfl_common/common/migrations/0023_userprofile_aimmo_badges.py b/cfl_common/common/migrations/0023_userprofile_aimmo_badges.py index 9a8b84f7d..a577c7052 100644 --- a/cfl_common/common/migrations/0023_userprofile_aimmo_badges.py +++ b/cfl_common/common/migrations/0023_userprofile_aimmo_badges.py @@ -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), ), ] diff --git a/cfl_common/common/migrations/0025_schoolteacherinvitation.py b/cfl_common/common/migrations/0025_schoolteacherinvitation.py index 3705416cd..d8af62bac 100644 --- a/cfl_common/common/migrations/0025_schoolteacherinvitation.py +++ b/cfl_common/common/migrations/0025_schoolteacherinvitation.py @@ -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", + ), + ), ], ), ] diff --git a/cfl_common/common/migrations/0026_teacher_remove_join_request.py b/cfl_common/common/migrations/0026_teacher_remove_join_request.py index 638103544..723429724 100644 --- a/cfl_common/common/migrations/0026_teacher_remove_join_request.py +++ b/cfl_common/common/migrations/0026_teacher_remove_join_request.py @@ -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), ), ] diff --git a/cfl_common/common/migrations/0027_class_created_by.py b/cfl_common/common/migrations/0027_class_created_by.py index 8e538b1c5..69309133c 100644 --- a/cfl_common/common/migrations/0027_class_created_by.py +++ b/cfl_common/common/migrations/0027_class_created_by.py @@ -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", + ), ), ] diff --git a/cfl_common/common/migrations/0028_coding_club_downloads.py b/cfl_common/common/migrations/0028_coding_club_downloads.py index 4ac09f9fa..4baa8806c 100644 --- a/cfl_common/common/migrations/0028_coding_club_downloads.py +++ b/cfl_common/common/migrations/0028_coding_club_downloads.py @@ -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), ), ] diff --git a/cfl_common/common/migrations/0029_dynamicelement.py b/cfl_common/common/migrations/0029_dynamicelement.py index b7ae229b2..6d9e09d00 100644 --- a/cfl_common/common/migrations/0029_dynamicelement.py +++ b/cfl_common/common/migrations/0029_dynamicelement.py @@ -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)), ], ), ] diff --git a/cfl_common/common/migrations/0030_add_maintenance_banner.py b/cfl_common/common/migrations/0030_add_maintenance_banner.py index 91b84c0be..ce88937b4 100644 --- a/cfl_common/common/migrations/0030_add_maintenance_banner.py +++ b/cfl_common/common/migrations/0030_add_maintenance_banner.py @@ -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)] diff --git a/cfl_common/common/migrations/0031_improve_admin_panel.py b/cfl_common/common/migrations/0031_improve_admin_panel.py index c91416ba7..eb7a80f62 100644 --- a/cfl_common/common/migrations/0031_improve_admin_panel.py +++ b/cfl_common/common/migrations/0031_improve_admin_panel.py @@ -7,32 +7,50 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0030_add_maintenance_banner'), + ("common", "0030_add_maintenance_banner"), ] operations = [ migrations.AlterModelOptions( - name='dailyactivity', - options={'verbose_name_plural': 'Daily activities'}, + name="dailyactivity", + options={"verbose_name_plural": "Daily activities"}, ), migrations.AlterField( - model_name='student', - name='blocked_time', + model_name="student", + name="blocked_time", field=models.DateTimeField(blank=True, null=True), ), migrations.AlterField( - model_name='student', - name='class_field', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='students', to='common.class'), + model_name="student", + name="class_field", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="students", + to="common.class", + ), ), migrations.AlterField( - model_name='student', - name='pending_class_request', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='class_request', to='common.class'), + model_name="student", + name="pending_class_request", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="class_request", + to="common.class", + ), ), migrations.AlterField( - model_name='teacher', - name='school', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teacher_school', to='common.school'), + model_name="teacher", + name="school", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + related_name="teacher_school", + to="common.school", + ), ), ] diff --git a/cfl_common/common/migrations/0032_dailyactivity_level_control_submits.py b/cfl_common/common/migrations/0032_dailyactivity_level_control_submits.py index e2ba29ab3..07b385aa5 100644 --- a/cfl_common/common/migrations/0032_dailyactivity_level_control_submits.py +++ b/cfl_common/common/migrations/0032_dailyactivity_level_control_submits.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0031_improve_admin_panel'), + ("common", "0031_improve_admin_panel"), ] operations = [ migrations.AddField( - model_name='dailyactivity', - name='level_control_submits', + model_name="dailyactivity", + name="level_control_submits", field=models.PositiveBigIntegerField(default=0), ), ] diff --git a/cfl_common/common/migrations/0033_password_reset_tracking_fields.py b/cfl_common/common/migrations/0033_password_reset_tracking_fields.py index 95a0230d4..1b411f33f 100644 --- a/cfl_common/common/migrations/0033_password_reset_tracking_fields.py +++ b/cfl_common/common/migrations/0033_password_reset_tracking_fields.py @@ -6,18 +6,18 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0032_dailyactivity_level_control_submits'), + ("common", "0032_dailyactivity_level_control_submits"), ] operations = [ migrations.AddField( - model_name='dailyactivity', - name='daily_indy_lockout_reset', + model_name="dailyactivity", + name="daily_indy_lockout_reset", field=models.PositiveIntegerField(default=0), ), migrations.AddField( - model_name='dailyactivity', - name='daily_teacher_lockout_reset', + model_name="dailyactivity", + name="daily_teacher_lockout_reset", field=models.PositiveIntegerField(default=0), ), ] diff --git a/cfl_common/common/migrations/0034_dailyactivity_daily_school_student_lockout_reset.py b/cfl_common/common/migrations/0034_dailyactivity_daily_school_student_lockout_reset.py index ad46443a5..79dcf4966 100644 --- a/cfl_common/common/migrations/0034_dailyactivity_daily_school_student_lockout_reset.py +++ b/cfl_common/common/migrations/0034_dailyactivity_daily_school_student_lockout_reset.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0033_password_reset_tracking_fields'), + ("common", "0033_password_reset_tracking_fields"), ] operations = [ migrations.AddField( - model_name='dailyactivity', - name='daily_school_student_lockout_reset', + model_name="dailyactivity", + name="daily_school_student_lockout_reset", field=models.PositiveIntegerField(default=0), ), ] diff --git a/cfl_common/common/migrations/0035_rename_lockout_fields.py b/cfl_common/common/migrations/0035_rename_lockout_fields.py index 791efd6e2..75c6a6529 100644 --- a/cfl_common/common/migrations/0035_rename_lockout_fields.py +++ b/cfl_common/common/migrations/0035_rename_lockout_fields.py @@ -5,23 +5,23 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0034_dailyactivity_daily_school_student_lockout_reset'), + ("common", "0034_dailyactivity_daily_school_student_lockout_reset"), ] operations = [ migrations.RenameField( - model_name='dailyactivity', - old_name='daily_indy_lockout_reset', - new_name='indy_lockout_resets', + model_name="dailyactivity", + old_name="daily_indy_lockout_reset", + new_name="indy_lockout_resets", ), migrations.RenameField( - model_name='dailyactivity', - old_name='daily_school_student_lockout_reset', - new_name='school_student_lockout_resets', + model_name="dailyactivity", + old_name="daily_school_student_lockout_reset", + new_name="school_student_lockout_resets", ), migrations.RenameField( - model_name='dailyactivity', - old_name='daily_teacher_lockout_reset', - new_name='teacher_lockout_resets', + model_name="dailyactivity", + old_name="daily_teacher_lockout_reset", + new_name="teacher_lockout_resets", ), ] diff --git a/cfl_common/common/migrations/0037_migrate_email_verification.py b/cfl_common/common/migrations/0037_migrate_email_verification.py index 6cbe1e3cd..1b2ad5be9 100644 --- a/cfl_common/common/migrations/0037_migrate_email_verification.py +++ b/cfl_common/common/migrations/0037_migrate_email_verification.py @@ -7,13 +7,13 @@ class Migration(migrations.Migration): ] def forwards(apps, schema_editor): - """ Finds the users of verified Email Verification objects and sets their `is_verified` to True """ + """Finds the users of verified Email Verification objects and sets their `is_verified` to True""" UserProfile = apps.get_model("common", "UserProfile") db_alias = schema_editor.connection.alias UserProfile.objects.using(db_alias).filter(user__email_verifications__verified=True).update(is_verified=True) def backwards(apps, schema_editor): - """ Finds the users of verified Email Verification objects and sets their `is_verified` to False """ + """Finds the users of verified Email Verification objects and sets their `is_verified` to False""" UserProfile = apps.get_model("common", "UserProfile") db_alias = schema_editor.connection.alias UserProfile.objects.using(db_alias).filter(user__email_verifications__verified=True).update(is_verified=False) diff --git a/cfl_common/common/migrations/0038_delete_emailverification.py b/cfl_common/common/migrations/0038_delete_emailverification.py index 7b1172951..7dd925b84 100644 --- a/cfl_common/common/migrations/0038_delete_emailverification.py +++ b/cfl_common/common/migrations/0038_delete_emailverification.py @@ -6,11 +6,11 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0037_migrate_email_verification'), + ("common", "0037_migrate_email_verification"), ] operations = [ migrations.DeleteModel( - name='EmailVerification', + name="EmailVerification", ), ] diff --git a/cfl_common/common/migrations/0039_copy_email_to_username.py b/cfl_common/common/migrations/0039_copy_email_to_username.py index 7029b0d48..f86e98f07 100644 --- a/cfl_common/common/migrations/0039_copy_email_to_username.py +++ b/cfl_common/common/migrations/0039_copy_email_to_username.py @@ -15,9 +15,4 @@ class Migration(migrations.Migration): ("common", "0038_delete_emailverification"), ] - 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)] diff --git a/cfl_common/common/migrations/0040_school_county.py b/cfl_common/common/migrations/0040_school_county.py index 68999bc76..3d187239d 100644 --- a/cfl_common/common/migrations/0040_school_county.py +++ b/cfl_common/common/migrations/0040_school_county.py @@ -6,13 +6,13 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0039_copy_email_to_username'), + ("common", "0039_copy_email_to_username"), ] operations = [ migrations.AddField( - model_name='school', - name='county', + model_name="school", + name="county", field=models.CharField(blank=True, max_length=50, null=True), ), ] diff --git a/cfl_common/common/migrations/0042_totalactivity.py b/cfl_common/common/migrations/0042_totalactivity.py index 18ff9dd35..351721e02 100644 --- a/cfl_common/common/migrations/0042_totalactivity.py +++ b/cfl_common/common/migrations/0042_totalactivity.py @@ -6,20 +6,20 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0041_populate_gb_counties'), + ("common", "0041_populate_gb_counties"), ] operations = [ migrations.CreateModel( - name='TotalActivity', + name="TotalActivity", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('teacher_registrations', models.PositiveIntegerField(default=0)), - ('student_registrations', models.PositiveIntegerField(default=0)), - ('independent_registrations', models.PositiveIntegerField(default=0)), + ("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), + ("teacher_registrations", models.PositiveIntegerField(default=0)), + ("student_registrations", models.PositiveIntegerField(default=0)), + ("independent_registrations", models.PositiveIntegerField(default=0)), ], options={ - 'verbose_name_plural': 'Total activity', + "verbose_name_plural": "Total activity", }, ), ] diff --git a/cfl_common/common/migrations/0044_update_activity_models.py b/cfl_common/common/migrations/0044_update_activity_models.py index ffdf9593f..2455dc588 100644 --- a/cfl_common/common/migrations/0044_update_activity_models.py +++ b/cfl_common/common/migrations/0044_update_activity_models.py @@ -6,28 +6,28 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0043_add_total_activity'), + ("common", "0043_add_total_activity"), ] operations = [ migrations.AddField( - model_name='dailyactivity', - name='anonymised_unverified_independents', + model_name="dailyactivity", + name="anonymised_unverified_independents", field=models.PositiveIntegerField(default=0), ), migrations.AddField( - model_name='dailyactivity', - name='anonymised_unverified_teachers', + model_name="dailyactivity", + name="anonymised_unverified_teachers", field=models.PositiveIntegerField(default=0), ), migrations.AddField( - model_name='totalactivity', - name='anonymised_unverified_independents', + model_name="totalactivity", + name="anonymised_unverified_independents", field=models.PositiveIntegerField(default=0), ), migrations.AddField( - model_name='totalactivity', - name='anonymised_unverified_teachers', + model_name="totalactivity", + name="anonymised_unverified_teachers", field=models.PositiveIntegerField(default=0), ), ] diff --git a/cfl_common/common/migrations/0045_otp.py b/cfl_common/common/migrations/0045_otp.py index 8ae203bcf..52d542176 100644 --- a/cfl_common/common/migrations/0045_otp.py +++ b/cfl_common/common/migrations/0045_otp.py @@ -6,18 +6,18 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0044_update_activity_models'), + ("common", "0044_update_activity_models"), ] operations = [ migrations.AddField( - model_name='userprofile', - name='last_otp_for_time', + model_name="userprofile", + name="last_otp_for_time", field=models.DateTimeField(blank=True, null=True), ), migrations.AddField( - model_name='userprofile', - name='otp_secret', + model_name="userprofile", + name="otp_secret", field=models.CharField(blank=True, max_length=40, null=True), ), ] diff --git a/cfl_common/common/migrations/0046_alter_school_country.py b/cfl_common/common/migrations/0046_alter_school_country.py index c743c2cee..64b5e1947 100644 --- a/cfl_common/common/migrations/0046_alter_school_country.py +++ b/cfl_common/common/migrations/0046_alter_school_country.py @@ -7,13 +7,13 @@ class Migration(migrations.Migration): dependencies = [ - ('common', '0045_otp'), + ("common", "0045_otp"), ] operations = [ migrations.AlterField( - model_name='school', - name='country', + model_name="school", + name="country", field=django_countries.fields.CountryField(blank=True, max_length=2, null=True), ), ] diff --git a/cfl_common/common/tests/utils/email.py b/cfl_common/common/tests/utils/email.py index 4a8d0d432..e8d195979 100644 --- a/cfl_common/common/tests/utils/email.py +++ b/cfl_common/common/tests/utils/email.py @@ -40,7 +40,9 @@ def follow_reset_email_link(browser, email): link = re.search("http.+/", message).group(0)[:-1] browser.get(link) - from portal.tests.pageObjects.portal.password_reset_form_page import PasswordResetPage + from portal.tests.pageObjects.portal.password_reset_form_page import ( + PasswordResetPage, + ) return PasswordResetPage(browser) @@ -70,6 +72,8 @@ def go_to_teacher_dashboard_page(browser): def go_to_independent_student_login_page(browser): - from portal.tests.pageObjects.portal.independent_login_page import IndependentStudentLoginPage + from portal.tests.pageObjects.portal.independent_login_page import ( + IndependentStudentLoginPage, + ) return IndependentStudentLoginPage(browser) diff --git a/cfl_common/common/tests/utils/student.py b/cfl_common/common/tests/utils/student.py index 500d18c25..7f69506a3 100644 --- a/cfl_common/common/tests/utils/student.py +++ b/cfl_common/common/tests/utils/student.py @@ -1,11 +1,11 @@ from builtins import range from typing import Tuple +from unittest.mock import patch from common.helpers.emails import generate_token from common.helpers.generators import generate_login_id from common.models import Class, Student from django.core import mail -from unittest.mock import Mock, patch from . import email diff --git a/cfl_common/common/tests/utils/teacher.py b/cfl_common/common/tests/utils/teacher.py index 100f9c24e..f0a129aa3 100644 --- a/cfl_common/common/tests/utils/teacher.py +++ b/cfl_common/common/tests/utils/teacher.py @@ -1,10 +1,10 @@ import random import sys +from unittest.mock import patch from common.helpers.emails import generate_token from common.models import Teacher from django.core import mail -from unittest.mock import patch from . import email diff --git a/portal/tests/test_independent_student.py b/portal/tests/test_independent_student.py index 1bfd1593a..87ab32d05 100644 --- a/portal/tests/test_independent_student.py +++ b/portal/tests/test_independent_student.py @@ -8,7 +8,10 @@ from common.models import JoinReleaseStudent from common.tests.utils import email as email_utils from common.tests.utils.classes import create_class_directly -from common.tests.utils.organisation import create_organisation_directly, join_teacher_to_organisation +from common.tests.utils.organisation import ( + create_organisation_directly, + join_teacher_to_organisation, +) from common.tests.utils.student import ( create_independent_student, create_independent_student_directly, diff --git a/portal/tests/test_teacher.py b/portal/tests/test_teacher.py index ac78c89a0..f12b5e73a 100644 --- a/portal/tests/test_teacher.py +++ b/portal/tests/test_teacher.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import re import time from datetime import timedelta from unittest.mock import ANY, Mock, patch @@ -8,12 +7,18 @@ import jwt from aimmo.models import Game -from common.mail import campaign_ids, send_dotdigital_email +from common.mail import campaign_ids from common.models import Class, Student, Teacher from common.tests.utils import email as email_utils from common.tests.utils.classes import create_class_directly -from common.tests.utils.organisation import create_organisation_directly, join_teacher_to_organisation -from common.tests.utils.student import create_independent_student_directly, create_school_student_directly +from common.tests.utils.organisation import ( + create_organisation_directly, + join_teacher_to_organisation, +) +from common.tests.utils.student import ( + create_independent_student_directly, + create_school_student_directly, +) from common.tests.utils.teacher import ( signup_duplicate_teacher_fail, signup_teacher, diff --git a/portal/tests/test_teacher_student.py b/portal/tests/test_teacher_student.py index 92d4ba337..b178fee98 100644 --- a/portal/tests/test_teacher_student.py +++ b/portal/tests/test_teacher_student.py @@ -6,7 +6,10 @@ import pytest from common.models import JoinReleaseStudent from common.tests.utils.classes import create_class_directly -from common.tests.utils.organisation import create_organisation_directly, join_teacher_to_organisation +from common.tests.utils.organisation import ( + create_organisation_directly, + join_teacher_to_organisation, +) from common.tests.utils.student import ( create_many_school_students, create_school_student, diff --git a/portal/tests/test_views.py b/portal/tests/test_views.py index 3e3c5a618..3952012e7 100644 --- a/portal/tests/test_views.py +++ b/portal/tests/test_views.py @@ -7,10 +7,21 @@ import PyPDF2 import pytest from aimmo.models import Game -from common.helpers.emails import NOTIFICATION_EMAIL -from common.models import Class, DailyActivity, School, Student, Teacher, TotalActivity, UserProfile, UserSession +from common.models import ( + Class, + DailyActivity, + School, + Student, + Teacher, + TotalActivity, + UserProfile, + UserSession, +) from common.tests.utils.classes import create_class_directly -from common.tests.utils.organisation import create_organisation_directly, join_teacher_to_organisation +from common.tests.utils.organisation import ( + create_organisation_directly, + join_teacher_to_organisation, +) from common.tests.utils.student import ( create_independent_student_directly, create_school_student_directly, diff --git a/portal/views/cron/user.py b/portal/views/cron/user.py index 94fd9e52c..ae676f9dc 100644 --- a/portal/views/cron/user.py +++ b/portal/views/cron/user.py @@ -1,7 +1,7 @@ import logging from datetime import datetime, timedelta -from common.helpers.emails import NOTIFICATION_EMAIL, generate_token_for_email, send_email +from common.helpers.emails import generate_token_for_email from common.mail import campaign_ids, send_dotdigital_email from common.models import DailyActivity, TotalActivity from django.contrib.auth.models import User diff --git a/pyproject.toml b/pyproject.toml index 645a471ca..5cea31143 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,3 +7,6 @@ line-length = 120 [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "example_project.portal_test_settings" + +[tool.isort] +profile = "black" \ No newline at end of file