codeforlife-portal 7.3.7__py2.py3-none-any.whl → 7.4.0__py2.py3-none-any.whl
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.
Potentially problematic release.
This version of codeforlife-portal might be problematic. Click here for more details.
- cfl_common/common/app_settings.py +0 -1
- cfl_common/common/helpers/emails.py +153 -36
- cfl_common/common/mail.py +5 -0
- {codeforlife_portal-7.3.7.dist-info → codeforlife_portal-7.4.0.dist-info}/METADATA +2 -2
- {codeforlife_portal-7.3.7.dist-info → codeforlife_portal-7.4.0.dist-info}/RECORD +30 -29
- example_project/portal_test_settings.py +1 -0
- example_project/settings.py +1 -0
- portal/__init__.py +1 -1
- portal/context_processors.py +5 -1
- portal/forms/dotmailer.py +39 -4
- portal/static/portal/img/rr_advanced.png +0 -0
- portal/static/portal/js/common.js +35 -5
- portal/static/portal/sass/modules/_colours.scss +3 -0
- portal/static/portal/sass/modules/_levels.scss +1 -1
- portal/static/portal/sass/modules/_mixins.scss +5 -0
- portal/static/portal/sass/partials/_buttons.scss +31 -3
- portal/static/portal/sass/partials/_header.scss +7 -6
- portal/static/portal/sass/partials/_popup.scss +7 -2
- portal/templates/portal/base.html +12 -3
- portal/templates/portal/home_learning.html +8 -7
- portal/templates/portal/partials/donate_popup.html +46 -0
- portal/templates/portal/partials/header.html +34 -30
- portal/tests/test_emails.py +17 -22
- portal/tests/{test_newsletter_footer.py → test_global_forms.py} +17 -1
- portal/urls.py +2 -0
- portal/views/dotmailer.py +30 -2
- portal/views/teacher/dashboard.py +174 -57
- {codeforlife_portal-7.3.7.dist-info → codeforlife_portal-7.4.0.dist-info}/LICENSE.md +0 -0
- {codeforlife_portal-7.3.7.dist-info → codeforlife_portal-7.4.0.dist-info}/WHEEL +0 -0
- {codeforlife_portal-7.3.7.dist-info → codeforlife_portal-7.4.0.dist-info}/top_level.txt +0 -0
|
@@ -2,16 +2,13 @@ from datetime import timedelta
|
|
|
2
2
|
from uuid import uuid4
|
|
3
3
|
|
|
4
4
|
from common.helpers.emails import (
|
|
5
|
-
INVITE_FROM,
|
|
6
|
-
NOTIFICATION_EMAIL,
|
|
7
5
|
DotmailerUserType,
|
|
8
6
|
add_to_dotmailer,
|
|
9
7
|
generate_token,
|
|
10
|
-
send_email,
|
|
11
8
|
update_email,
|
|
12
9
|
)
|
|
13
10
|
from common.helpers.generators import get_random_username
|
|
14
|
-
from common.mail import campaign_ids, send_dotdigital_email
|
|
11
|
+
from common.mail import address_book_ids, campaign_ids, send_dotdigital_email
|
|
15
12
|
from common.models import (
|
|
16
13
|
Class,
|
|
17
14
|
JoinReleaseStudent,
|
|
@@ -50,7 +47,6 @@ from portal.helpers.ratelimit import (
|
|
|
50
47
|
RATELIMIT_METHOD,
|
|
51
48
|
clear_ratelimit_cache_for_user,
|
|
52
49
|
)
|
|
53
|
-
|
|
54
50
|
from .teach import create_class
|
|
55
51
|
|
|
56
52
|
|
|
@@ -92,11 +88,19 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
92
88
|
update_school_form = None
|
|
93
89
|
|
|
94
90
|
if school:
|
|
95
|
-
coworkers = Teacher.objects.filter(school=school).order_by(
|
|
91
|
+
coworkers = Teacher.objects.filter(school=school).order_by(
|
|
92
|
+
"new_user__last_name", "new_user__first_name"
|
|
93
|
+
)
|
|
96
94
|
|
|
97
|
-
sent_invites =
|
|
95
|
+
sent_invites = (
|
|
96
|
+
SchoolTeacherInvitation.objects.filter(school=school)
|
|
97
|
+
if teacher.is_admin
|
|
98
|
+
else []
|
|
99
|
+
)
|
|
98
100
|
|
|
99
|
-
update_school_form = OrganisationForm(
|
|
101
|
+
update_school_form = OrganisationForm(
|
|
102
|
+
user=request.user, current_school=school
|
|
103
|
+
)
|
|
100
104
|
update_school_form.fields["name"].initial = school.name
|
|
101
105
|
update_school_form.fields["country"].initial = school.country
|
|
102
106
|
update_school_form.fields["county"].initial = school.county
|
|
@@ -121,7 +125,9 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
121
125
|
if request.method == "POST":
|
|
122
126
|
if can_process_update_school_form(request, is_admin):
|
|
123
127
|
anchor = "school-details"
|
|
124
|
-
update_school_form = OrganisationForm(
|
|
128
|
+
update_school_form = OrganisationForm(
|
|
129
|
+
request.POST, user=request.user, current_school=school
|
|
130
|
+
)
|
|
125
131
|
anchor = process_update_school_form(request, school, anchor)
|
|
126
132
|
|
|
127
133
|
elif "create_class" in request.POST:
|
|
@@ -131,14 +137,23 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
131
137
|
class_teacher = teacher
|
|
132
138
|
# If the logged in teacher is an admin, then get the class teacher from the selected dropdown
|
|
133
139
|
if teacher.is_admin:
|
|
134
|
-
class_teacher = get_object_or_404(
|
|
135
|
-
|
|
140
|
+
class_teacher = get_object_or_404(
|
|
141
|
+
Teacher, id=create_class_form.cleaned_data["teacher"]
|
|
142
|
+
)
|
|
143
|
+
created_class = create_class(
|
|
144
|
+
create_class_form, class_teacher, class_creator=teacher
|
|
145
|
+
)
|
|
136
146
|
messages.success(
|
|
137
147
|
request,
|
|
138
|
-
"The class '{className}' has been created successfully.".format(
|
|
148
|
+
"The class '{className}' has been created successfully.".format(
|
|
149
|
+
className=created_class.name
|
|
150
|
+
),
|
|
139
151
|
)
|
|
140
152
|
return HttpResponseRedirect(
|
|
141
|
-
reverse_lazy(
|
|
153
|
+
reverse_lazy(
|
|
154
|
+
"view_class",
|
|
155
|
+
kwargs={"access_code": created_class.access_code},
|
|
156
|
+
)
|
|
142
157
|
)
|
|
143
158
|
|
|
144
159
|
elif request.POST.get("show_onboarding_complete") == "1":
|
|
@@ -165,11 +180,11 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
165
180
|
expiry=timezone.now() + timedelta(days=30),
|
|
166
181
|
)
|
|
167
182
|
|
|
168
|
-
account_exists = User.objects.filter(
|
|
183
|
+
account_exists = User.objects.filter(
|
|
184
|
+
email=invited_teacher_email
|
|
185
|
+
).exists()
|
|
169
186
|
|
|
170
|
-
registration_link = (
|
|
171
|
-
f"{request.build_absolute_uri(reverse('invited_teacher', kwargs={'token': token}))} "
|
|
172
|
-
)
|
|
187
|
+
registration_link = f"{request.build_absolute_uri(reverse('invited_teacher', kwargs={'token': token}))} "
|
|
173
188
|
|
|
174
189
|
campaign_id = (
|
|
175
190
|
campaign_ids["invite_teacher_with_account"]
|
|
@@ -180,7 +195,10 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
180
195
|
send_dotdigital_email(
|
|
181
196
|
campaign_id,
|
|
182
197
|
[invited_teacher_email],
|
|
183
|
-
personalization_values={
|
|
198
|
+
personalization_values={
|
|
199
|
+
"SCHOOL_NAME": school.name,
|
|
200
|
+
"REGISTRATION_LINK": registration_link,
|
|
201
|
+
},
|
|
184
202
|
)
|
|
185
203
|
|
|
186
204
|
messages.success(
|
|
@@ -194,15 +212,23 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
194
212
|
elif "delete_account" in request.POST:
|
|
195
213
|
delete_account_form = DeleteAccountForm(request.user, request.POST)
|
|
196
214
|
if not delete_account_form.is_valid():
|
|
197
|
-
messages.warning(
|
|
215
|
+
messages.warning(
|
|
216
|
+
request,
|
|
217
|
+
"Your account was not deleted due to incorrect password.",
|
|
218
|
+
)
|
|
198
219
|
else:
|
|
199
220
|
delete_account_confirm = True
|
|
200
221
|
else:
|
|
201
222
|
anchor = "account"
|
|
202
|
-
update_account_form = TeacherEditAccountForm(
|
|
203
|
-
|
|
204
|
-
request, teacher, anchor
|
|
223
|
+
update_account_form = TeacherEditAccountForm(
|
|
224
|
+
request.user, request.POST
|
|
205
225
|
)
|
|
226
|
+
(
|
|
227
|
+
changing_email,
|
|
228
|
+
new_email,
|
|
229
|
+
changing_password,
|
|
230
|
+
anchor,
|
|
231
|
+
) = process_update_account_form(request, teacher, anchor)
|
|
206
232
|
if changing_email:
|
|
207
233
|
logout(request)
|
|
208
234
|
messages.success(
|
|
@@ -210,19 +236,33 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
210
236
|
"Your email will be changed once you have verified it, until then "
|
|
211
237
|
"you can still log in with your old email.",
|
|
212
238
|
)
|
|
213
|
-
return render(
|
|
239
|
+
return render(
|
|
240
|
+
request,
|
|
241
|
+
"portal/email_verification_needed.html",
|
|
242
|
+
{"usertype": "TEACHER"},
|
|
243
|
+
)
|
|
214
244
|
|
|
215
245
|
if changing_password:
|
|
216
246
|
logout(request)
|
|
217
|
-
messages.success(
|
|
247
|
+
messages.success(
|
|
248
|
+
request, "Please login using your new password."
|
|
249
|
+
)
|
|
218
250
|
return HttpResponseRedirect(reverse_lazy("teacher_login"))
|
|
219
251
|
|
|
220
252
|
if teacher.is_admin:
|
|
221
253
|
# Making sure the current teacher classes come up first
|
|
222
254
|
classes = school.classes()
|
|
223
|
-
[
|
|
255
|
+
[
|
|
256
|
+
classes.insert(0, classes.pop(i))
|
|
257
|
+
for i in range(len(classes))
|
|
258
|
+
if classes[i].teacher.id == teacher.id
|
|
259
|
+
]
|
|
224
260
|
|
|
225
|
-
requests = list(
|
|
261
|
+
requests = list(
|
|
262
|
+
Student.objects.filter(
|
|
263
|
+
pending_class_request__teacher__school=school
|
|
264
|
+
)
|
|
265
|
+
)
|
|
226
266
|
[
|
|
227
267
|
requests.insert(0, requests.pop(i))
|
|
228
268
|
for i in range(len(requests))
|
|
@@ -231,7 +271,9 @@ def dashboard_teacher_view(request, is_admin):
|
|
|
231
271
|
|
|
232
272
|
else:
|
|
233
273
|
classes = Class.objects.filter(teacher=teacher)
|
|
234
|
-
requests = Student.objects.filter(
|
|
274
|
+
requests = Student.objects.filter(
|
|
275
|
+
pending_class_request__teacher=teacher
|
|
276
|
+
)
|
|
235
277
|
|
|
236
278
|
return render(
|
|
237
279
|
request,
|
|
@@ -265,7 +307,9 @@ def check_backup_tokens(request):
|
|
|
265
307
|
# For teachers using 2FA, find out how many backup tokens they have
|
|
266
308
|
if using_two_factor(request.user):
|
|
267
309
|
try:
|
|
268
|
-
backup_tokens = request.user.staticdevice_set.all()[
|
|
310
|
+
backup_tokens = request.user.staticdevice_set.all()[
|
|
311
|
+
0
|
|
312
|
+
].token_set.count()
|
|
269
313
|
except Exception:
|
|
270
314
|
backup_tokens = 0
|
|
271
315
|
|
|
@@ -273,7 +317,9 @@ def check_backup_tokens(request):
|
|
|
273
317
|
|
|
274
318
|
|
|
275
319
|
def process_update_school_form(request, school, old_anchor):
|
|
276
|
-
update_school_form = OrganisationForm(
|
|
320
|
+
update_school_form = OrganisationForm(
|
|
321
|
+
request.POST, user=request.user, current_school=school
|
|
322
|
+
)
|
|
277
323
|
if update_school_form.is_valid():
|
|
278
324
|
data = update_school_form.cleaned_data
|
|
279
325
|
name = data.get("name", "")
|
|
@@ -286,7 +332,10 @@ def process_update_school_form(request, school, old_anchor):
|
|
|
286
332
|
|
|
287
333
|
anchor = "#"
|
|
288
334
|
|
|
289
|
-
messages.success(
|
|
335
|
+
messages.success(
|
|
336
|
+
request,
|
|
337
|
+
"You have updated the details for your school or club successfully.",
|
|
338
|
+
)
|
|
290
339
|
else:
|
|
291
340
|
anchor = old_anchor
|
|
292
341
|
|
|
@@ -302,7 +351,9 @@ def process_update_account_form(request, teacher, old_anchor):
|
|
|
302
351
|
data = update_account_form.cleaned_data
|
|
303
352
|
|
|
304
353
|
# check not default value for CharField
|
|
305
|
-
changing_password = check_update_password(
|
|
354
|
+
changing_password = check_update_password(
|
|
355
|
+
update_account_form, teacher.new_user, request, data
|
|
356
|
+
)
|
|
306
357
|
|
|
307
358
|
teacher.new_user.first_name = data["first_name"]
|
|
308
359
|
teacher.new_user.last_name = data["last_name"]
|
|
@@ -317,7 +368,9 @@ def process_update_account_form(request, teacher, old_anchor):
|
|
|
317
368
|
# Reset ratelimit cache after successful account details update
|
|
318
369
|
clear_ratelimit_cache_for_user(teacher.new_user.username)
|
|
319
370
|
|
|
320
|
-
messages.success(
|
|
371
|
+
messages.success(
|
|
372
|
+
request, "Your account details have been successfully changed."
|
|
373
|
+
)
|
|
321
374
|
else:
|
|
322
375
|
anchor = old_anchor
|
|
323
376
|
|
|
@@ -349,7 +402,9 @@ def organisation_kick(request, pk):
|
|
|
349
402
|
|
|
350
403
|
check_teacher_is_authorised(teacher, user)
|
|
351
404
|
|
|
352
|
-
success_message =
|
|
405
|
+
success_message = (
|
|
406
|
+
"The teacher has been successfully removed from your school or club."
|
|
407
|
+
)
|
|
353
408
|
|
|
354
409
|
classes = Class.objects.filter(teacher=teacher)
|
|
355
410
|
for klass in classes:
|
|
@@ -359,10 +414,14 @@ def organisation_kick(request, pk):
|
|
|
359
414
|
klass.teacher = new_teacher
|
|
360
415
|
klass.save()
|
|
361
416
|
|
|
362
|
-
success_message = success_message.replace(
|
|
417
|
+
success_message = success_message.replace(
|
|
418
|
+
".", " and their classes were successfully transferred."
|
|
419
|
+
)
|
|
363
420
|
|
|
364
421
|
classes = Class.objects.filter(teacher=teacher)
|
|
365
|
-
teachers = Teacher.objects.filter(school=teacher.school).exclude(
|
|
422
|
+
teachers = Teacher.objects.filter(school=teacher.school).exclude(
|
|
423
|
+
id=teacher.id
|
|
424
|
+
)
|
|
366
425
|
|
|
367
426
|
if classes.exists():
|
|
368
427
|
messages.info(
|
|
@@ -404,18 +463,24 @@ def invite_toggle_admin(request, invite_id):
|
|
|
404
463
|
invite.save()
|
|
405
464
|
|
|
406
465
|
if invite.invited_teacher_is_admin:
|
|
407
|
-
messages.success(
|
|
466
|
+
messages.success(
|
|
467
|
+
request, "Administrator invite status has been given successfully"
|
|
468
|
+
)
|
|
408
469
|
send_dotdigital_email(
|
|
409
470
|
campaign_ids["admin_given"],
|
|
410
471
|
[invite.invited_teacher_email],
|
|
411
472
|
personalization_values={
|
|
412
473
|
"SCHOOL_CLUB_NAME": invite.school,
|
|
413
|
-
"MANAGEMENT_LINK": request.build_absolute_uri(
|
|
474
|
+
"MANAGEMENT_LINK": request.build_absolute_uri(
|
|
475
|
+
reverse("dashboard")
|
|
476
|
+
),
|
|
414
477
|
},
|
|
415
478
|
)
|
|
416
479
|
|
|
417
480
|
else:
|
|
418
|
-
messages.success(
|
|
481
|
+
messages.success(
|
|
482
|
+
request, "Administrator invite status has been revoked successfully"
|
|
483
|
+
)
|
|
419
484
|
send_dotdigital_email(
|
|
420
485
|
campaign_ids["admin_revoked"],
|
|
421
486
|
[invite.invited_teacher_email],
|
|
@@ -438,13 +503,17 @@ def organisation_toggle_admin(request, pk):
|
|
|
438
503
|
teacher.save()
|
|
439
504
|
|
|
440
505
|
if teacher.is_admin:
|
|
441
|
-
messages.success(
|
|
506
|
+
messages.success(
|
|
507
|
+
request, "Administrator status has been given successfully."
|
|
508
|
+
)
|
|
442
509
|
send_dotdigital_email(
|
|
443
510
|
campaign_ids["admin_given"],
|
|
444
511
|
[teacher.new_user.email],
|
|
445
512
|
personalization_values={
|
|
446
513
|
"SCHOOL_CLUB_NAME": teacher.school.name,
|
|
447
|
-
"MANAGEMENT_LINK": request.build_absolute_uri(
|
|
514
|
+
"MANAGEMENT_LINK": request.build_absolute_uri(
|
|
515
|
+
reverse("dashboard")
|
|
516
|
+
),
|
|
448
517
|
},
|
|
449
518
|
)
|
|
450
519
|
else:
|
|
@@ -452,9 +521,12 @@ def organisation_toggle_admin(request, pk):
|
|
|
452
521
|
[
|
|
453
522
|
unshare_level(level, teacher.new_user)
|
|
454
523
|
for level in levels_shared_with(teacher.new_user)
|
|
455
|
-
if hasattr(level.owner, "student")
|
|
524
|
+
if hasattr(level.owner, "student")
|
|
525
|
+
and not teacher.teaches(level.owner)
|
|
456
526
|
]
|
|
457
|
-
messages.success(
|
|
527
|
+
messages.success(
|
|
528
|
+
request, "Administrator status has been revoked successfully."
|
|
529
|
+
)
|
|
458
530
|
send_dotdigital_email(
|
|
459
531
|
campaign_ids["admin_revoked"],
|
|
460
532
|
[teacher.new_user.email],
|
|
@@ -474,7 +546,11 @@ def teacher_disable_2FA(request, pk):
|
|
|
474
546
|
if teacher.school != user.school or not user.is_admin:
|
|
475
547
|
raise Http404
|
|
476
548
|
|
|
477
|
-
[
|
|
549
|
+
[
|
|
550
|
+
device.delete()
|
|
551
|
+
for device in devices_for_user(teacher.new_user)
|
|
552
|
+
if request.method == "POST"
|
|
553
|
+
]
|
|
478
554
|
|
|
479
555
|
return HttpResponseRedirect(reverse_lazy("dashboard"))
|
|
480
556
|
|
|
@@ -487,10 +563,14 @@ def teacher_accept_student_request(request, pk):
|
|
|
487
563
|
|
|
488
564
|
check_student_request_can_be_handled(request, student)
|
|
489
565
|
|
|
490
|
-
students = Student.objects.filter(
|
|
566
|
+
students = Student.objects.filter(
|
|
567
|
+
class_field=student.pending_class_request
|
|
568
|
+
).order_by("new_user__first_name")
|
|
491
569
|
|
|
492
570
|
if request.method == "POST":
|
|
493
|
-
form = TeacherAddExternalStudentForm(
|
|
571
|
+
form = TeacherAddExternalStudentForm(
|
|
572
|
+
student.pending_class_request, request.POST
|
|
573
|
+
)
|
|
494
574
|
if form.is_valid():
|
|
495
575
|
data = form.cleaned_data
|
|
496
576
|
student.class_field = student.pending_class_request
|
|
@@ -505,7 +585,9 @@ def teacher_accept_student_request(request, pk):
|
|
|
505
585
|
student.new_user.userprofile.save()
|
|
506
586
|
|
|
507
587
|
# log the data
|
|
508
|
-
joinrelease = JoinReleaseStudent.objects.create(
|
|
588
|
+
joinrelease = JoinReleaseStudent.objects.create(
|
|
589
|
+
student=student, action_type=JoinReleaseStudent.JOIN
|
|
590
|
+
)
|
|
509
591
|
joinrelease.save()
|
|
510
592
|
|
|
511
593
|
return render(
|
|
@@ -515,13 +597,19 @@ def teacher_accept_student_request(request, pk):
|
|
|
515
597
|
)
|
|
516
598
|
else:
|
|
517
599
|
form = TeacherAddExternalStudentForm(
|
|
518
|
-
student.pending_class_request,
|
|
600
|
+
student.pending_class_request,
|
|
601
|
+
initial={"name": student.new_user.first_name},
|
|
519
602
|
)
|
|
520
603
|
|
|
521
604
|
return render(
|
|
522
605
|
request,
|
|
523
606
|
"portal/teach/teacher_add_external_student.html",
|
|
524
|
-
{
|
|
607
|
+
{
|
|
608
|
+
"students": students,
|
|
609
|
+
"class": student.pending_class_request,
|
|
610
|
+
"student": student,
|
|
611
|
+
"form": form,
|
|
612
|
+
},
|
|
525
613
|
)
|
|
526
614
|
|
|
527
615
|
|
|
@@ -556,7 +644,10 @@ def teacher_reject_student_request(request, pk):
|
|
|
556
644
|
student.pending_class_request = None
|
|
557
645
|
student.save()
|
|
558
646
|
|
|
559
|
-
messages.success(
|
|
647
|
+
messages.success(
|
|
648
|
+
request,
|
|
649
|
+
"Request from external/independent student has been rejected successfully.",
|
|
650
|
+
)
|
|
560
651
|
|
|
561
652
|
return HttpResponseRedirect(reverse_lazy("dashboard"))
|
|
562
653
|
|
|
@@ -571,11 +662,17 @@ def delete_teacher_invite(request, token):
|
|
|
571
662
|
|
|
572
663
|
# auth the user before deletion
|
|
573
664
|
if invite is None or teacher.school != invite.school:
|
|
574
|
-
messages.error(
|
|
665
|
+
messages.error(
|
|
666
|
+
request,
|
|
667
|
+
"You do not have permission to perform this action or the invite does not exist",
|
|
668
|
+
)
|
|
575
669
|
else:
|
|
576
670
|
invite_teacher_first_name = invite.invited_teacher_first_name
|
|
577
671
|
invite.anonymise()
|
|
578
|
-
messages.success(
|
|
672
|
+
messages.success(
|
|
673
|
+
request,
|
|
674
|
+
f"Invite for {invite_teacher_first_name} successfully deleted",
|
|
675
|
+
)
|
|
579
676
|
return HttpResponseRedirect(reverse_lazy("dashboard"))
|
|
580
677
|
|
|
581
678
|
|
|
@@ -589,7 +686,10 @@ def resend_invite_teacher(request, token):
|
|
|
589
686
|
|
|
590
687
|
# auth the user before deletion
|
|
591
688
|
if invite is None or teacher.school != invite.school:
|
|
592
|
-
messages.error(
|
|
689
|
+
messages.error(
|
|
690
|
+
request,
|
|
691
|
+
"You do not have permission to perform this action or the invite does not exist",
|
|
692
|
+
)
|
|
593
693
|
else:
|
|
594
694
|
invite.expiry = timezone.now() + timedelta(days=30)
|
|
595
695
|
invite.save()
|
|
@@ -608,7 +708,10 @@ def resend_invite_teacher(request, token):
|
|
|
608
708
|
send_dotdigital_email(
|
|
609
709
|
campaign_id,
|
|
610
710
|
[invite.invited_teacher_email],
|
|
611
|
-
personalization_values={
|
|
711
|
+
personalization_values={
|
|
712
|
+
"SCHOOL_NAME": invite.school,
|
|
713
|
+
"REGISTRATION_LINK": registration_link,
|
|
714
|
+
},
|
|
612
715
|
)
|
|
613
716
|
|
|
614
717
|
return HttpResponseRedirect(reverse_lazy("dashboard"))
|
|
@@ -620,7 +723,10 @@ def invited_teacher(request, token):
|
|
|
620
723
|
if request.method == "POST":
|
|
621
724
|
invited_teacher_form = InvitedTeacherForm(request.POST)
|
|
622
725
|
if invited_teacher_form.is_valid():
|
|
623
|
-
messages.success(
|
|
726
|
+
messages.success(
|
|
727
|
+
request,
|
|
728
|
+
"Your account has been created successfully, please log in.",
|
|
729
|
+
)
|
|
624
730
|
return HttpResponseRedirect(reverse_lazy("teacher_login"))
|
|
625
731
|
else:
|
|
626
732
|
invited_teacher_form = InvitedTeacherForm()
|
|
@@ -628,13 +734,18 @@ def invited_teacher(request, token):
|
|
|
628
734
|
return render(
|
|
629
735
|
request,
|
|
630
736
|
"portal/teach/invited.html",
|
|
631
|
-
{
|
|
737
|
+
{
|
|
738
|
+
"invited_teacher_form": invited_teacher_form,
|
|
739
|
+
"error_message": error_message,
|
|
740
|
+
},
|
|
632
741
|
)
|
|
633
742
|
|
|
634
743
|
|
|
635
744
|
def process_teacher_invitation(request, token):
|
|
636
745
|
try:
|
|
637
|
-
invitation = SchoolTeacherInvitation.objects.get(
|
|
746
|
+
invitation = SchoolTeacherInvitation.objects.get(
|
|
747
|
+
token=token, expiry__gt=timezone.now()
|
|
748
|
+
)
|
|
638
749
|
except SchoolTeacherInvitation.DoesNotExist:
|
|
639
750
|
return "Uh oh, the Invitation does not exist or it has expired. 😞"
|
|
640
751
|
|
|
@@ -670,7 +781,13 @@ def process_teacher_invitation(request, token):
|
|
|
670
781
|
# Add to Dotmailer if they ticked the box
|
|
671
782
|
if newsletter_ticked:
|
|
672
783
|
user = invited_teacher.user.user
|
|
673
|
-
add_to_dotmailer(
|
|
784
|
+
add_to_dotmailer(
|
|
785
|
+
user.first_name,
|
|
786
|
+
user.last_name,
|
|
787
|
+
user.email,
|
|
788
|
+
address_book_ids["newsletter"],
|
|
789
|
+
DotmailerUserType.TEACHER,
|
|
790
|
+
)
|
|
674
791
|
|
|
675
792
|
# Anonymise the invitation
|
|
676
793
|
invitation.anonymise()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|