diff --git a/rca/people/templates/admin/panels/student_page_inline_panel.html b/rca/people/templates/admin/panels/student_page_inline_panel.html index fa4af3f44..2a100ae7a 100644 --- a/rca/people/templates/admin/panels/student_page_inline_panel.html +++ b/rca/people/templates/admin/panels/student_page_inline_panel.html @@ -3,9 +3,11 @@ {% comment "Always render the formset so the form can be saved" %}{% endcomment %} {{ self.formset.management_form }} -{% comment "Hide the visibe form fields to non-superusers" %}{% endcomment %} -{% if request.user.is_superuser %} - +{% comment %} +Hide the visible form fields to non-superusers. We only want to toggle the visibility since +the fields must still exist in the template so it's part of the POSTed data. +{% endcomment %} +
diff --git a/rca/people/tests/test_models.py b/rca/people/tests/test_models.py index 87b69412a..ae9aad126 100644 --- a/rca/people/tests/test_models.py +++ b/rca/people/tests/test_models.py @@ -275,3 +275,60 @@ def test_create_page_validation_no_collection(self): "If you are adding a student user account so a student can access " "this page, an image collection must be added.", ) + + +class TestStudentPageEdit(TestCase, WagtailTestUtils): + + create_view_name = "student_account_create" + + def setUp(self): + super().setUp() + self.student = UserFactory(username="student") + self.user = UserFactory(is_superuser=True) + self.student_group = Group.objects.get(name="Students") + admin_permission = Permission.objects.get(codename="access_admin") + self.student_group.permissions.add(admin_permission) + self.student.groups.add(self.student_group) + self.student.set_password("test") + self.student.save() + + self.home_page = HomePage.objects.first() + self.home_page.add_child( + instance=StudentIndexPage( + title="Students", + slug="students", + introduction="students", + ) + ) + self.student_index = StudentIndexPage.objects.first() + GroupPagePermission.objects.create( + group=self.student_group, + page=self.student_index, + permission_type="edit", + ) + self.student_index.add_child( + instance=StudentPage( + title="A student", slug="a-student", first_name="a", last_name="student" + ) + ) + self.student_page = StudentPage.objects.first() + + self.url = reverse("wagtailadmin_pages:edit", args=(self.student_page.id,)) + + def test_related_school_fields_should_be_in_page(self): + # As a superuser, there should be an option to add related schools and I should see it. + self.client.force_login(self.user) + response = self.client.get(self.url) + self.assertContains(response, "Add related schools") + self.assertContains( + response, '
\n