cfl-common 8.9.8__tar.gz → 8.9.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. {cfl_common-8.9.8 → cfl_common-8.9.10}/PKG-INFO +7 -7
  2. {cfl_common-8.9.8 → cfl_common-8.9.10}/cfl_common.egg-info/PKG-INFO +7 -7
  3. {cfl_common-8.9.8 → cfl_common-8.9.10}/cfl_common.egg-info/requires.txt +6 -6
  4. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/app_settings.py +5 -2
  5. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/helpers/emails.py +18 -48
  6. {cfl_common-8.9.8 → cfl_common-8.9.10}/MANIFEST.in +0 -0
  7. {cfl_common-8.9.8 → cfl_common-8.9.10}/cfl_common.egg-info/SOURCES.txt +0 -0
  8. {cfl_common-8.9.8 → cfl_common-8.9.10}/cfl_common.egg-info/dependency_links.txt +0 -0
  9. {cfl_common-8.9.8 → cfl_common-8.9.10}/cfl_common.egg-info/top_level.txt +0 -0
  10. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/__init__.py +0 -0
  11. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/apps.py +0 -0
  12. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/context_processors.py +0 -0
  13. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/csp_config.py +0 -0
  14. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/fixtures/aimmo_characters.json +0 -0
  15. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/fixtures/aimmo_characters2.json +0 -0
  16. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/fixtures/aimmo_characters3.json +0 -0
  17. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/helpers/__init__.py +0 -0
  18. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/helpers/data_migration_loader.py +0 -0
  19. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/helpers/generators.py +0 -0
  20. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/helpers/organisation.py +0 -0
  21. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/mail.py +0 -0
  22. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0001_initial.py +0 -0
  23. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0002_emailverification.py +0 -0
  24. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0003_aimmocharacter.py +0 -0
  25. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0004_add_aimmocharacters.py +0 -0
  26. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0005_add_worksheets.py +0 -0
  27. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0006_update_aimmo_character_image_path.py +0 -0
  28. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0007_add_pdf_names_to_first_two_worksheets.py +0 -0
  29. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0008_unlock_worksheet_3.py +0 -0
  30. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0009_add_blocked_time_to_teacher_and_student.py +0 -0
  31. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0010_remove_teacher_title.py +0 -0
  32. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0011_student_login_id.py +0 -0
  33. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0012_usersession.py +0 -0
  34. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0013_class_school.py +0 -0
  35. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0014_login_type.py +0 -0
  36. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0015_dailyactivity.py +0 -0
  37. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0016_joinreleasestudent.py +0 -0
  38. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0017_copy_email_to_username.py +0 -0
  39. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0018_update_aimmo_character_image_path.py +0 -0
  40. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0019_aimmocharacter_alt.py +0 -0
  41. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0020_class_is_active_and_null_access_code.py +0 -0
  42. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0021_school_is_active.py +0 -0
  43. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0022_school_cleanup.py +0 -0
  44. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0023_userprofile_aimmo_badges.py +0 -0
  45. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0024_teacher_invited_by.py +0 -0
  46. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0025_schoolteacherinvitation.py +0 -0
  47. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0026_teacher_remove_join_request.py +0 -0
  48. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0027_class_created_by.py +0 -0
  49. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0028_coding_club_downloads.py +0 -0
  50. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0029_dynamicelement.py +0 -0
  51. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0030_add_maintenance_banner.py +0 -0
  52. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0031_improve_admin_panel.py +0 -0
  53. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0032_dailyactivity_level_control_submits.py +0 -0
  54. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0033_password_reset_tracking_fields.py +0 -0
  55. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0034_dailyactivity_daily_school_student_lockout_reset.py +0 -0
  56. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0035_rename_lockout_fields.py +0 -0
  57. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0036_rename_awaiting_email_verification_userprofile_is_verified.py +0 -0
  58. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0037_migrate_email_verification.py +0 -0
  59. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0038_delete_emailverification.py +0 -0
  60. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0039_copy_email_to_username.py +0 -0
  61. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0040_school_county.py +0 -0
  62. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0041_populate_gb_counties.py +0 -0
  63. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0042_totalactivity.py +0 -0
  64. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0043_add_total_activity.py +0 -0
  65. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0044_update_activity_models.py +0 -0
  66. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0045_otp.py +0 -0
  67. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0046_alter_school_country.py +0 -0
  68. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0047_delete_school_postcode.py +0 -0
  69. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0048_unique_school_names.py +0 -0
  70. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0049_anonymise_orphan_users.py +0 -0
  71. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0050_anonymise_orphan_schools.py +0 -0
  72. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0051_verify_returning_users.py +0 -0
  73. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0052_add_cse_fields.py +0 -0
  74. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0053_clean_class_data.py +0 -0
  75. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0054_delete_aimmo_models.py +0 -0
  76. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0055_alter_schoolteacherinvitation_token.py +0 -0
  77. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0056_set_non_school_teachers_as_non_admins.py +0 -0
  78. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0057_teacher_teacher__is_admin.py +0 -0
  79. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/0058_userprofile_google_refresh_token_and_more.py +0 -0
  80. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/migrations/__init__.py +0 -0
  81. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/models.py +0 -0
  82. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/permissions.py +0 -0
  83. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/static/common/img/RR_logo.svg +0 -0
  84. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/static/common/img/brain.svg +0 -0
  85. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/templates/common/freshdesk_widget.html +0 -0
  86. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/templates/common/onetrust_cookies_consent_notice.html +0 -0
  87. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/__init__.py +0 -0
  88. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_anonymise_orphan_schools.py +0 -0
  89. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_anonymise_orphan_users.py +0 -0
  90. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_blocked_time.py +0 -0
  91. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_remove_teacher_title.py +0 -0
  92. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_unique_school_names.py +0 -0
  93. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_migration_verify_returning_users.py +0 -0
  94. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/test_models.py +0 -0
  95. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/__init__.py +0 -0
  96. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/classes.py +0 -0
  97. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/email.py +0 -0
  98. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/organisation.py +0 -0
  99. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/student.py +0 -0
  100. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/teacher.py +0 -0
  101. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/tests/utils/user.py +0 -0
  102. {cfl_common-8.9.8 → cfl_common-8.9.10}/common/utils.py +0 -0
  103. {cfl_common-8.9.8 → cfl_common-8.9.10}/pyproject.toml +0 -0
  104. {cfl_common-8.9.8 → cfl_common-8.9.10}/setup.cfg +0 -0
  105. {cfl_common-8.9.8 → cfl_common-8.9.10}/setup.py +0 -0
@@ -1,28 +1,28 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cfl-common
3
- Version: 8.9.8
3
+ Version: 8.9.10
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Operating System :: OS Independent
6
- Requires-Dist: asgiref==3.10.0; python_version >= "3.9"
7
- Requires-Dist: certifi==2025.10.5; python_version >= "3.7"
6
+ Requires-Dist: asgiref==3.11.0; python_version >= "3.9"
7
+ Requires-Dist: certifi==2025.11.12; python_version >= "3.7"
8
8
  Requires-Dist: cffi==2.0.0; platform_python_implementation != "PyPy"
9
9
  Requires-Dist: charset-normalizer==3.4.4; python_version >= "3.7"
10
10
  Requires-Dist: cryptography==44.0.1; python_version >= "3.7" and python_full_version not in "3.9.0, 3.9.1"
11
11
  Requires-Dist: diff-match-patch==20241021; python_version >= "3.7"
12
- Requires-Dist: django==5.1.14; python_version >= "3.10"
12
+ Requires-Dist: django==5.1.15; python_version >= "3.10"
13
13
  Requires-Dist: django-countries==7.6.1
14
14
  Requires-Dist: django-csp==3.8
15
15
  Requires-Dist: django-formtools==2.5.1; python_version >= "3.8"
16
16
  Requires-Dist: django-import-export==4.2.0; python_version >= "3.9"
17
17
  Requires-Dist: django-otp==1.6.3; python_version >= "3.7"
18
- Requires-Dist: django-phonenumber-field==8.3.0; python_version >= "3.9"
18
+ Requires-Dist: django-phonenumber-field==8.4.0; python_version >= "3.10"
19
19
  Requires-Dist: django-pipeline==4.0.0; python_version >= "3.9"
20
20
  Requires-Dist: django-two-factor-auth==1.17.0; python_version >= "3.8"
21
21
  Requires-Dist: djangorestframework==3.16.0; python_version >= "3.9"
22
22
  Requires-Dist: idna==3.11; python_version >= "3.8"
23
23
  Requires-Dist: libsass==0.23.0; python_version >= "3.8"
24
24
  Requires-Dist: more-itertools==8.7.0; python_version >= "3.5"
25
- Requires-Dist: numpy==2.3.4; python_version >= "3.11"
25
+ Requires-Dist: numpy==2.3.5; python_version >= "3.11"
26
26
  Requires-Dist: pandas==2.3.3; python_version >= "3.9"
27
27
  Requires-Dist: pgeocode==0.4.0; python_version >= "3.8"
28
28
  Requires-Dist: pycparser==2.23; implementation_name != "PyPy"
@@ -34,7 +34,7 @@ Requires-Dist: qrcode==7.4.2; python_version >= "3.7"
34
34
  Requires-Dist: requests==2.32.5; python_version >= "3.9"
35
35
  Requires-Dist: setuptools==80.9.0; python_version >= "3.9"
36
36
  Requires-Dist: six==1.17.0; python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"
37
- Requires-Dist: sqlparse==0.5.3; python_version >= "3.8"
37
+ Requires-Dist: sqlparse==0.5.4; python_version >= "3.8"
38
38
  Requires-Dist: tablib==3.7.0; python_version >= "3.9"
39
39
  Requires-Dist: typing-extensions==4.15.0; python_version >= "3.9"
40
40
  Requires-Dist: tzdata==2025.2; python_version >= "2"
@@ -1,28 +1,28 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cfl-common
3
- Version: 8.9.8
3
+ Version: 8.9.10
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Operating System :: OS Independent
6
- Requires-Dist: asgiref==3.10.0; python_version >= "3.9"
7
- Requires-Dist: certifi==2025.10.5; python_version >= "3.7"
6
+ Requires-Dist: asgiref==3.11.0; python_version >= "3.9"
7
+ Requires-Dist: certifi==2025.11.12; python_version >= "3.7"
8
8
  Requires-Dist: cffi==2.0.0; platform_python_implementation != "PyPy"
9
9
  Requires-Dist: charset-normalizer==3.4.4; python_version >= "3.7"
10
10
  Requires-Dist: cryptography==44.0.1; python_version >= "3.7" and python_full_version not in "3.9.0, 3.9.1"
11
11
  Requires-Dist: diff-match-patch==20241021; python_version >= "3.7"
12
- Requires-Dist: django==5.1.14; python_version >= "3.10"
12
+ Requires-Dist: django==5.1.15; python_version >= "3.10"
13
13
  Requires-Dist: django-countries==7.6.1
14
14
  Requires-Dist: django-csp==3.8
15
15
  Requires-Dist: django-formtools==2.5.1; python_version >= "3.8"
16
16
  Requires-Dist: django-import-export==4.2.0; python_version >= "3.9"
17
17
  Requires-Dist: django-otp==1.6.3; python_version >= "3.7"
18
- Requires-Dist: django-phonenumber-field==8.3.0; python_version >= "3.9"
18
+ Requires-Dist: django-phonenumber-field==8.4.0; python_version >= "3.10"
19
19
  Requires-Dist: django-pipeline==4.0.0; python_version >= "3.9"
20
20
  Requires-Dist: django-two-factor-auth==1.17.0; python_version >= "3.8"
21
21
  Requires-Dist: djangorestframework==3.16.0; python_version >= "3.9"
22
22
  Requires-Dist: idna==3.11; python_version >= "3.8"
23
23
  Requires-Dist: libsass==0.23.0; python_version >= "3.8"
24
24
  Requires-Dist: more-itertools==8.7.0; python_version >= "3.5"
25
- Requires-Dist: numpy==2.3.4; python_version >= "3.11"
25
+ Requires-Dist: numpy==2.3.5; python_version >= "3.11"
26
26
  Requires-Dist: pandas==2.3.3; python_version >= "3.9"
27
27
  Requires-Dist: pgeocode==0.4.0; python_version >= "3.8"
28
28
  Requires-Dist: pycparser==2.23; implementation_name != "PyPy"
@@ -34,7 +34,7 @@ Requires-Dist: qrcode==7.4.2; python_version >= "3.7"
34
34
  Requires-Dist: requests==2.32.5; python_version >= "3.9"
35
35
  Requires-Dist: setuptools==80.9.0; python_version >= "3.9"
36
36
  Requires-Dist: six==1.17.0; python_version >= "2.7" and python_version not in "3.0, 3.1, 3.2, 3.3"
37
- Requires-Dist: sqlparse==0.5.3; python_version >= "3.8"
37
+ Requires-Dist: sqlparse==0.5.4; python_version >= "3.8"
38
38
  Requires-Dist: tablib==3.7.0; python_version >= "3.9"
39
39
  Requires-Dist: typing-extensions==4.15.0; python_version >= "3.9"
40
40
  Requires-Dist: tzdata==2025.2; python_version >= "2"
@@ -17,16 +17,17 @@ python-dateutil==2.9.0.post0
17
17
  six==1.17.0
18
18
 
19
19
  [:python_version >= "3.10"]
20
- django==5.1.14
20
+ django==5.1.15
21
+ django-phonenumber-field==8.4.0
21
22
 
22
23
  [:python_version >= "3.11"]
23
- numpy==2.3.4
24
+ numpy==2.3.5
24
25
 
25
26
  [:python_version >= "3.5"]
26
27
  more-itertools==8.7.0
27
28
 
28
29
  [:python_version >= "3.7"]
29
- certifi==2025.10.5
30
+ certifi==2025.11.12
30
31
  charset-normalizer==3.4.4
31
32
  diff-match-patch==20241021
32
33
  django-otp==1.6.3
@@ -42,13 +43,12 @@ django-two-factor-auth==1.17.0
42
43
  idna==3.11
43
44
  libsass==0.23.0
44
45
  pgeocode==0.4.0
45
- sqlparse==0.5.3
46
+ sqlparse==0.5.4
46
47
  wheel==0.45.1
47
48
 
48
49
  [:python_version >= "3.9"]
49
- asgiref==3.10.0
50
+ asgiref==3.11.0
50
51
  django-import-export==4.2.0
51
- django-phonenumber-field==8.3.0
52
52
  django-pipeline==4.0.0
53
53
  djangorestframework==3.16.0
54
54
  pandas==2.3.3
@@ -54,12 +54,15 @@ MODULE_NAME = getattr(settings, "MODULE_NAME", "local")
54
54
  COOKIE_MANAGEMENT_ENABLED = getattr(settings, "COOKIE_MANAGEMENT_ENABLED", True)
55
55
 
56
56
 
57
- def domain():
57
+ def domain(request=None):
58
58
  """Returns the full domain depending on whether it's local, dev, staging or prod."""
59
+ if hasattr(settings, "SERVICE_BASE_URL"):
60
+ return getattr(settings, "SERVICE_BASE_URL")
61
+
59
62
  domain = "https://www.codeforlife.education"
60
63
 
61
64
  if MODULE_NAME == "local":
62
- domain = "localhost:8000"
65
+ domain = f"http://{request.get_host()}" if request is not None else "localhost:8000"
63
66
  elif MODULE_NAME == "staging" or MODULE_NAME == "dev":
64
67
  domain = f"https://{MODULE_NAME}-dot-decent-digit-629.appspot.com"
65
68
 
@@ -20,15 +20,9 @@ from django.utils import timezone
20
20
  from requests import delete, get, post, put
21
21
  from requests.exceptions import RequestException
22
22
 
23
- NOTIFICATION_EMAIL = (
24
- "Code For Life Notification <" + app_settings.EMAIL_ADDRESS + ">"
25
- )
26
- VERIFICATION_EMAIL = (
27
- "Code For Life Verification <" + app_settings.EMAIL_ADDRESS + ">"
28
- )
29
- PASSWORD_RESET_EMAIL = (
30
- "Code For Life Password Reset <" + app_settings.EMAIL_ADDRESS + ">"
31
- )
23
+ NOTIFICATION_EMAIL = "Code For Life Notification <" + app_settings.EMAIL_ADDRESS + ">"
24
+ VERIFICATION_EMAIL = "Code For Life Verification <" + app_settings.EMAIL_ADDRESS + ">"
25
+ PASSWORD_RESET_EMAIL = "Code For Life Password Reset <" + app_settings.EMAIL_ADDRESS + ">"
32
26
  INVITE_FROM = "Code For Life Invitation <" + app_settings.EMAIL_ADDRESS + ">"
33
27
 
34
28
 
@@ -52,9 +46,7 @@ def generate_token_for_email(email: str, new_email: str = ""):
52
46
  "email": email,
53
47
  "new_email": new_email,
54
48
  "email_verification_token": uuid4().hex[:30],
55
- "expires": (
56
- timezone.now() + datetime.timedelta(hours=1)
57
- ).timestamp(),
49
+ "expires": (timezone.now() + datetime.timedelta(hours=1)).timestamp(),
58
50
  },
59
51
  settings.SECRET_KEY,
60
52
  algorithm="HS256",
@@ -87,9 +79,7 @@ def send_email(
87
79
  )
88
80
 
89
81
 
90
- def send_verification_email(
91
- request, user, data, new_email=None, age=None, school=None
92
- ):
82
+ def send_verification_email(request, user, data, new_email=None, age=None, school=None):
93
83
  """
94
84
  Sends emails relating to email address verification.
95
85
 
@@ -119,7 +109,7 @@ def send_verification_email(
119
109
  if age is None:
120
110
  # if the user is a released student
121
111
  if hasattr(user, "new_student") and school is not None:
122
- url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': verification}))}"
112
+ url = f"{app_settings.domain(request)}{reverse('verify_email', kwargs={'token': verification})}"
123
113
 
124
114
  send_dotdigital_email(
125
115
  campaign_ids["verify_released_student"],
@@ -130,7 +120,7 @@ def send_verification_email(
130
120
  },
131
121
  )
132
122
  else:
133
- url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': verification}))}"
123
+ url = f"{app_settings.domain(request)}{reverse('verify_email', kwargs={'token': verification})}"
134
124
 
135
125
  send_dotdigital_email(
136
126
  campaign_ids["verify_new_user"],
@@ -149,7 +139,7 @@ def send_verification_email(
149
139
  # if the user is an independent student
150
140
  else:
151
141
  if age < 13:
152
- url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': verification}))}"
142
+ url = f"{app_settings.domain(request)}{reverse('verify_email', kwargs={'token': verification})}"
153
143
  send_dotdigital_email(
154
144
  campaign_ids["verify_new_user_via_parent"],
155
145
  [user.email],
@@ -159,7 +149,7 @@ def send_verification_email(
159
149
  },
160
150
  )
161
151
  else:
162
- url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': verification}))}"
152
+ url = f"{app_settings.domain(request)}{reverse('verify_email', kwargs={'token': verification})}"
163
153
  send_dotdigital_email(
164
154
  campaign_ids["verify_new_user"],
165
155
  [user.email],
@@ -177,7 +167,7 @@ def send_verification_email(
177
167
  # verifying change of email address.
178
168
  else:
179
169
  verification = generate_token(user, new_email)
180
- url = f"{request.build_absolute_uri(reverse('verify_email', kwargs={'token': verification}))}"
170
+ url = f"{app_settings.domain(request)}{reverse('verify_email', kwargs={'token': verification})}"
181
171
  send_dotdigital_email(
182
172
  campaign_ids["email_change_verification"],
183
173
  [new_email],
@@ -194,9 +184,7 @@ def add_to_dotmailer(
194
184
  ):
195
185
  try:
196
186
  create_contact(first_name, last_name, email)
197
- add_contact_to_address_book(
198
- first_name, last_name, email, address_book_id, user_type
199
- )
187
+ add_contact_to_address_book(first_name, last_name, email, address_book_id, user_type)
200
188
  except RequestException:
201
189
  return HttpResponse(status=404)
202
190
 
@@ -261,18 +249,12 @@ def add_contact_to_address_book(
261
249
  )
262
250
 
263
251
  if user_type is not None:
264
- specific_address_book_url = (
265
- app_settings.DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL
266
- )
252
+ specific_address_book_url = app_settings.DOTMAILER_NO_ACCOUNT_ADDRESS_BOOK_URL
267
253
 
268
254
  if user_type == DotmailerUserType.TEACHER:
269
- specific_address_book_url = (
270
- app_settings.DOTMAILER_TEACHER_ADDRESS_BOOK_URL
271
- )
255
+ specific_address_book_url = app_settings.DOTMAILER_TEACHER_ADDRESS_BOOK_URL
272
256
  elif user_type == DotmailerUserType.STUDENT:
273
- specific_address_book_url = (
274
- app_settings.DOTMAILER_STUDENT_ADDRESS_BOOK_URL
275
- )
257
+ specific_address_book_url = app_settings.DOTMAILER_STUDENT_ADDRESS_BOOK_URL
276
258
 
277
259
  post(
278
260
  specific_address_book_url,
@@ -286,9 +268,7 @@ def delete_contact(email: str):
286
268
  user = get_dotmailer_user_by_email(email)
287
269
  user_id = user.get("id")
288
270
  if user_id:
289
- url = app_settings.DOTMAILER_DELETE_USER_BY_ID_URL.replace(
290
- "ID", str(user_id)
291
- )
271
+ url = app_settings.DOTMAILER_DELETE_USER_BY_ID_URL.replace("ID", str(user_id))
292
272
  delete(
293
273
  url,
294
274
  auth=(
@@ -303,9 +283,7 @@ def delete_contact(email: str):
303
283
  def get_dotmailer_user_by_email(email):
304
284
  url = app_settings.DOTMAILER_GET_USER_BY_EMAIL_URL.replace("EMAIL", email)
305
285
 
306
- response = get(
307
- url, auth=(app_settings.DOTMAILER_USER, app_settings.DOTMAILER_PASSWORD)
308
- )
286
+ response = get(url, auth=(app_settings.DOTMAILER_USER, app_settings.DOTMAILER_PASSWORD))
309
287
 
310
288
  return json.loads(response.content)
311
289
 
@@ -313,9 +291,7 @@ def get_dotmailer_user_by_email(email):
313
291
  def add_consent_record_to_dotmailer_user(user):
314
292
  consent_date_time = datetime.datetime.now().__str__()
315
293
 
316
- url = app_settings.DOTMAILER_PUT_CONSENT_DATA_URL.replace(
317
- "USER_ID", str(user["id"])
318
- )
294
+ url = app_settings.DOTMAILER_PUT_CONSENT_DATA_URL.replace("USER_ID", str(user["id"]))
319
295
  body = {
320
296
  "contact": {
321
297
  "email": user["email"],
@@ -323,13 +299,7 @@ def add_consent_record_to_dotmailer_user(user):
323
299
  "emailType": user["emailType"],
324
300
  "dataFields": user["dataFields"],
325
301
  },
326
- "consentFields": [
327
- {
328
- "fields": [
329
- {"key": "DATETIMECONSENTED", "value": consent_date_time}
330
- ]
331
- }
332
- ],
302
+ "consentFields": [{"fields": [{"key": "DATETIMECONSENTED", "value": consent_date_time}]}],
333
303
  }
334
304
 
335
305
  put(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes