From ed339b9167d7e5eed271e7e53b04750735ce59fa Mon Sep 17 00:00:00 2001 From: besque Date: Fri, 25 Oct 2024 12:48:35 +0530 Subject: [PATCH 1/4] Fixed teacher invitation password visibility and strength checker --- portal/forms/teach.py | 1 + portal/templates/portal/teach/invited.html | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/portal/forms/teach.py b/portal/forms/teach.py index 15f49e063..cc22a80b9 100644 --- a/portal/forms/teach.py +++ b/portal/forms/teach.py @@ -18,6 +18,7 @@ class InvitedTeacherForm(forms.Form): + prefix = 'teacher_signup' teacher_password = forms.CharField( help_text="Enter a password", widget=forms.PasswordInput( diff --git a/portal/templates/portal/teach/invited.html b/portal/templates/portal/teach/invited.html index 42f9c1504..6825276cf 100644 --- a/portal/templates/portal/teach/invited.html +++ b/portal/templates/portal/teach/invited.html @@ -20,7 +20,7 @@

Complete registration

-
+ {% csrf_token %} @@ -29,7 +29,9 @@

Complete registration

- {{ invited_teacher_form.teacher_password }} + {{ invited_teacher_form.teacher_password }} +
{{ invited_teacher_form.teacher_password.help_text }} {{ invited_teacher_form.teacher_password.errors }} @@ -37,7 +39,9 @@

Complete registration

- {{ invited_teacher_form.teacher_confirm_password }} + {{ invited_teacher_form.teacher_confirm_password }} +
{{ invited_teacher_form.teacher_confirm_password.help_text }} {{ invited_teacher_form.teacher_confirm_password.errors }} @@ -73,10 +77,14 @@

Complete registration

- +{% include "portal/partials/service_unavailable_popup.html" %} + -{% endblock content %} + + +{% endblock content %} \ No newline at end of file From cbf4be77d237478f5bcd1eda8cea464f6be42c0d Mon Sep 17 00:00:00 2001 From: besque Date: Fri, 25 Oct 2024 16:01:08 +0530 Subject: [PATCH 2/4] fix: Update id generation while maintaining field names --- portal/forms/teach.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/portal/forms/teach.py b/portal/forms/teach.py index cc22a80b9..8c324b13a 100644 --- a/portal/forms/teach.py +++ b/portal/forms/teach.py @@ -19,6 +19,12 @@ class InvitedTeacherForm(forms.Form): prefix = 'teacher_signup' + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for field in self.fields.values(): + field.widget.attrs['id'] = f'id_teacher_signup-{field.name}' + teacher_password = forms.CharField( help_text="Enter a password", widget=forms.PasswordInput( From 9f7d2dde2527416d822463892d77086c223170c4 Mon Sep 17 00:00:00 2001 From: besque Date: Fri, 25 Oct 2024 16:46:08 +0530 Subject: [PATCH 3/4] fix: update field name access in form initialization --- portal/forms/teach.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/portal/forms/teach.py b/portal/forms/teach.py index 8c324b13a..553bfa8d4 100644 --- a/portal/forms/teach.py +++ b/portal/forms/teach.py @@ -19,11 +19,11 @@ class InvitedTeacherForm(forms.Form): prefix = 'teacher_signup' - + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - for field in self.fields.values(): - field.widget.attrs['id'] = f'id_teacher_signup-{field.name}' + for field_name, field in self.fields.items(): + field.widget.attrs['id'] = f'id_teacher_signup-{field_name}' teacher_password = forms.CharField( help_text="Enter a password", From 50493241f9b2aab7d5cfcc94bf9239a61c56ae22 Mon Sep 17 00:00:00 2001 From: besque Date: Fri, 25 Oct 2024 20:33:36 +0530 Subject: [PATCH 4/4] fix: update test field names to match form prefix --- portal/tests/test_invite_teacher.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/portal/tests/test_invite_teacher.py b/portal/tests/test_invite_teacher.py index 8251f6997..729a7d1ab 100644 --- a/portal/tests/test_invite_teacher.py +++ b/portal/tests/test_invite_teacher.py @@ -63,9 +63,9 @@ def test_invite_teacher_successful(self): response = client.post( invitation_url, { - "teacher_password": invited_teacher_password, - "teacher_confirm_password": invited_teacher_password, - "consent_ticked": "on", + "teacher_signup-teacher_password": invited_teacher_password, + "teacher_signup-teacher_confirm_password": invited_teacher_password, + "teacher_signup-consent_ticked": "on", }, )