@@ -275,3 +275,60 @@ def test_create_page_validation_no_collection(self):
275
275
"If you are adding a student user account so a student can access "
276
276
"this page, an image collection must be added." ,
277
277
)
278
+
279
+
280
+ class TestStudentPageEdit (TestCase , WagtailTestUtils ):
281
+
282
+ create_view_name = "student_account_create"
283
+
284
+ def setUp (self ):
285
+ super ().setUp ()
286
+ self .student = UserFactory (username = "student" )
287
+ self .user = UserFactory (is_superuser = True )
288
+ self .student_group = Group .objects .get (name = "Students" )
289
+ admin_permission = Permission .objects .get (codename = "access_admin" )
290
+ self .student_group .permissions .add (admin_permission )
291
+ self .student .groups .add (self .student_group )
292
+ self .student .set_password ("test" )
293
+ self .student .save ()
294
+
295
+ self .home_page = HomePage .objects .first ()
296
+ self .home_page .add_child (
297
+ instance = StudentIndexPage (
298
+ title = "Students" ,
299
+ slug = "students" ,
300
+ introduction = "students" ,
301
+ )
302
+ )
303
+ self .student_index = StudentIndexPage .objects .first ()
304
+ GroupPagePermission .objects .create (
305
+ group = self .student_group ,
306
+ page = self .student_index ,
307
+ permission_type = "edit" ,
308
+ )
309
+ self .student_index .add_child (
310
+ instance = StudentPage (
311
+ title = "A student" , slug = "a-student" , first_name = "a" , last_name = "student"
312
+ )
313
+ )
314
+ self .student_page = StudentPage .objects .first ()
315
+
316
+ self .url = reverse ("wagtailadmin_pages:edit" , args = (self .student_page .id ,))
317
+
318
+ def test_related_school_fields_should_be_in_page (self ):
319
+ # As a superuser, there should be an option to add related schools and I should see it.
320
+ self .client .force_login (self .user )
321
+ response = self .client .get (self .url )
322
+ self .assertContains (response , "Add related schools" )
323
+ self .assertContains (
324
+ response , '<div >\n <ul class="multiple" id="id_related_schools-FORMS">'
325
+ )
326
+
327
+ # As a student, I shouldn't see it but it should still be in the template.
328
+ self .client .force_login (self .student )
329
+ response = self .client .get (self .url )
330
+ self .assertContains (response , "Add related schools" )
331
+ self .assertContains (
332
+ response ,
333
+ '<div style="display: none;">\n <ul class="multiple" id="id_related_schools-FORMS">' ,
334
+ )
0 commit comments