Skip to content

Messages: only teachers and admins get Add and Remove in a class group - #2088

Closed
svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:fix/messages-class-group-members
Closed

svaka2000 wants to merge 1 commit into
Open-Coding-Society:mainfrom
svaka2000:fix/messages-class-group-members

Conversation

@svaka2000

Copy link
Copy Markdown
Contributor

Open-Coding-Society/spring#309 lets only teachers and admins add or remove people in a class group (CSSE, CSP, CSA or CSH). The Members dialog on /dm still showed Add and Remove there to everyone, so once spring#309 is deployed, a student's click would just fail with "Could not add" or "Could not remove". Now only teachers and admins see them there.

  • Everyone else sees who is in the class, without the "Add a classmate" search, the Remove buttons or the empty Action column.
  • Students still join and leave their class groups through the classes on their Profile, like before.
  • Any other group works the same as before: its members can add and remove people.
  • Hiding the "Add a classmate" search would leave keyboard focus on the page behind the dialog, so the dialog now focuses its Close button instead.

A student opening Members on CSA:

A student's Members dialog on CSA, with the member list and no Add or Remove

A teacher opening the same dialog:

A teacher's Members dialog on CSA, with Remove buttons and a search that found someone to add

The student's dialog on a phone, in Light and Midnight:

The student's Members dialog on a phone in the Light theme The student's Members dialog on a phone in the Midnight theme

Other notes:

  • Paths are under _projects/systems/messages/.
  • canChangeMembers(me, group) in js/messages-model.js decides it: true for ROLE_TEACHER or ROLE_ADMIN (the roles spring#309's isStaff checks) or for any group that isn't a class group. isClassGroup now trims the name like Spring does, so a group named "CSA " is a class group on both sides.
  • createDialog in js/dialogs.js now focuses the first data-focus field that is showing, or Close. The other dialogs on /dm always show theirs, so they don't change.
  • The code doesn't need spring#309, so it can merge before or after it. If it goes first, students just stop seeing Add and Remove in class groups a little early.
  • Messages: offer each account only what Spring lets it do #2082 (mentors in Messages) makes the same createDialog change and hides the same controls for mentors with its canManage flag. The two conflict in js/group-dialogs.js and one line of AGENTS_MD_DOCUMENTATION.md. Whichever merges first, I'll update the other to use canManage && canChangeMembers(me, group), and I tried that merge.
  • I added tests/members_dialog.test.mjs and tests in tests/messages_model.test.mjs, and updated the README and both AGENTS files. node --test _projects/systems/messages/tests/*.test.mjs passes.
  • I checked /dm at laptop and phone widths in Chrome and WebKit, with fake Spring answers for a student and a teacher.

How to try it:

  1. Run Spring, Flask and the site locally, and sign in as a student who is in a class group (add the class on your Profile).
  2. Open that class group in /dm and click Members. You see the list with no Add or Remove.
  3. Sign in as a teacher or admin in that class (add it on their Profile) and open the same Members dialog. Add and Remove are there.
  4. As the student, open Members on a group that isn't a class group and has someone else in it. Add and Remove are there.

A class group's members come from the classes on each student's Profile, and
spring#309 lets only teachers and admins change them through POST and DELETE
/api/groups/{id}/members/{personId}. Members now shows Add and Remove on a class
group only to them (canChangeMembers). Everyone else sees the list, without the
Action column. With the search hidden, createDialog focuses the close button, so
focus stays in the dialog. isClassGroup now trims the name before comparing, as
Spring's ClassGroupMembershipService does.
svaka2000 added a commit to svaka2000/Pages-JJ that referenced this pull request Nov 26, 2026
…roup rule

Open-Coding-Society#2088 hides Members' Action column on a class group for anyone who isn't
a teacher or admin, so the dialog now toggles the column's header, and
the tests give it one. A student no longer gets Add in a class group, so
the class-group refusal test opens the dialog as a teacher.
@svaka2000

Copy link
Copy Markdown
Contributor Author

Combined into #2091 with the same commits.

@svaka2000 svaka2000 closed this Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant